- You are here:
- Main › Forum › Application Support
cBB Chat 1.1.0 - Online users question on forum
7 posts
• Page 1 of 1
-
- dlv
- Posts: 7
- Joined: Sun Feb 08, 2015 8:32 am
Sun Feb 15, 2015 4:41 pm • via Web
First of all i want to say that this chat is working perfect on my test forum 3.1.3
Now my question:
In the section "Who is online" on the portal of my forum i added some code to display the names of the users who are currently in the chat (just under the users who are online on the forum).
This is working perfect so far, but when a user logs out from the forum (whitout login out from the chat) his name stays there. In my chat options i putt the option of disconnection time into 5 minutes, but after 5 minutes the user still display in the oline list op the portal?
I also saw that in the databse the user_online status stays 1 instead of 0?
When a user does a manual logout from the chat, then this problem does not exist and the user_online in the database is set to 0.
I supose this is a session problem. Who can i solve this problem in my code?
Now my question:
In the section "Who is online" on the portal of my forum i added some code to display the names of the users who are currently in the chat (just under the users who are online on the forum).
- Code: Select all
//Begin cbb chatters online
$chatters = '';
$sql = 'SELECT u.user_id, u.username, u.user_colour
FROM *****_chat_users c, ' . USERS_TABLE . ' u
WHERE c.user_online = 1 AND c.user_id = u.user_id';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
$chatters .= get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) . ', ';
}
$this->db->sql_freeresult($result);
if ($chatters == '') {$chatters = 'No users in the chat.';}
else {$chatters = 'Users in the chat: ' . substr($chatters, 0, -2);}
$this->template->assign_var('CHATTERS',$chatters);
// End cbb chatters online
This is working perfect so far, but when a user logs out from the forum (whitout login out from the chat) his name stays there. In my chat options i putt the option of disconnection time into 5 minutes, but after 5 minutes the user still display in the oline list op the portal?
I also saw that in the databse the user_online status stays 1 instead of 0?
When a user does a manual logout from the chat, then this problem does not exist and the user_online in the database is set to 0.
I supose this is a session problem. Who can i solve this problem in my code?
- IvanPF
- Administrator
- Posts: 2010
- Joined: Fri Jun 17, 2011 12:15 am
- Location: España (Spain)
Sun Feb 15, 2015 6:01 pm • via Web
Hi,
Users are not disconnected from chat because phpBB 3.1.3 does not have any events that executes when the user disconnects from the forum.
If you want to do this you need to edit the core of phpBB and do this:
1. Open /phpbb/session.php
2. Find:
3. After add:
Users are not disconnected from chat because phpBB 3.1.3 does not have any events that executes when the user disconnects from the forum.
If you want to do this you need to edit the core of phpBB and do this:
1. Open /phpbb/session.php
2. Find:
- Code: Select all
$provider->logout($this->data, $new_session);
3. After add:
- Code: Select all
if(!empty($config['chat_enabled']))
{
global $chat;
if(!defined('CHAT_USERS_TABLE'))
{
include($phpbb_root_path . "ext/canidev/chat/constants.$phpEx");
}
// Delete from chat users if no banned
$sql = 'DELETE FROM ' . CHAT_USERS_TABLE . '
WHERE user_id = ' . $this->data['user_id'] . "
OR user_ip = '" . $this->ip . "'
AND exclude_time = 0";
$db->sql_query($sql);
// Set the correct user status if banned
if(!$db->sql_affectedrows())
{
$sql = 'UPDATE ' . CHAT_USERS_TABLE . '
SET user_online = 0
WHERE user_id = ' . $this->data['user_id'] . '
AND exclude_time > 0';
$db->sql_query($sql);
}
// Delete private messages
if(method_exists($chat, 'obtain_room'))
{
$room_ary = $chat->obtain_rooms();
$sql = 'DELETE FROM ' . CHAT_MESSAGES_TABLE . '
WHERE (poster_id = ' . $this->data['user_id'] . '
AND ' . $db->sql_in_set('dest_key', array_keys($room_ary), true) . ')
OR dest_key = ' . $this->data['user_id'];
$db->sql_query($sql);
}
$cookie_expire = $this->time_now - 31536000;
$this->set_cookie('chat_key', '', $cookie_expire);
$this->set_cookie('chat_lastcheck', '', $cookie_expire);
}
-
- dlv
- Posts: 7
- Joined: Sun Feb 08, 2015 8:32 am
Sun Feb 15, 2015 7:23 pm • via Web
Thanks for your quick answer and excellent support
I just edited the /phpbb/session.php file like you said and it's working, but not exactely like i wanted.
For testing purposes i put the "Away" status on 1 minute and the "Disconnect" status on 2 minutes.
If you go to the chat page (auto connected) and log out from the forum (for example after 30 secs), the users don't appear in the block "Who is online" when you go to the Portal. This is working fine.
If you go to the chat page (auto connected) and stay at the chat page and wait till you are disconnected, the users don't appear in the block "Who is online" when you go to the Portal. This is also working fine.
But when you go to the chat page (auto connected) and for example after 30 secs. you surf on other places on the forum and you go for example after 5 or 10 minutes to the Portal page the users still appear as online in the block "Who is online" at the Portal? While after 1 minute they should be auto disconnected... This is not working correct.
I really hope you can fix this issue
I just edited the /phpbb/session.php file like you said and it's working, but not exactely like i wanted.
For testing purposes i put the "Away" status on 1 minute and the "Disconnect" status on 2 minutes.
If you go to the chat page (auto connected) and log out from the forum (for example after 30 secs), the users don't appear in the block "Who is online" when you go to the Portal. This is working fine.
If you go to the chat page (auto connected) and stay at the chat page and wait till you are disconnected, the users don't appear in the block "Who is online" when you go to the Portal. This is also working fine.
But when you go to the chat page (auto connected) and for example after 30 secs. you surf on other places on the forum and you go for example after 5 or 10 minutes to the Portal page the users still appear as online in the block "Who is online" at the Portal? While after 1 minute they should be auto disconnected... This is not working correct.
I really hope you can fix this issue
- IvanPF
- Administrator
- Posts: 2010
- Joined: Fri Jun 17, 2011 12:15 am
- Location: España (Spain)
Sun Feb 15, 2015 7:31 pm • via Web
Ok, try this. In your code, find:
and replace with:
- Code: Select all
WHERE c.user_online = 1 AND c.user_id = u.user_id';
and replace with:
- Code: Select all
WHERE c.user_online = 1 AND c.user_id = u.user_id
AND c.user_lastjoin > ' . $chat->time_limit;
-
- dlv
- Posts: 7
- Joined: Sun Feb 08, 2015 8:32 am
Sun Feb 15, 2015 9:22 pm • via Web
That returns into an error.
- Code: Select all
SQL ERROR [ mysql4 ]
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 3 [1064]
- IvanPF
- Administrator
- Posts: 2010
- Joined: Fri Jun 17, 2011 12:15 am
- Location: España (Spain)
Sun Feb 15, 2015 10:43 pm • via Web
If your code is inside a function, you must append the follow line before the SQL query.
- Code: Select all
global $chat;
-
- dlv
- Posts: 7
- Joined: Sun Feb 08, 2015 8:32 am
Mon Feb 16, 2015 5:31 pm • via Web
It's all working correct now
Thank you very very much for the great support and excellent chat
Thank you very very much for the great support and excellent chat
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests
- External Links
- phpBB Official
- phpBB Official (Spanish)
- Raul Arroyo Monzo
- PasionReef
- About CaniDev
- Terms of use
- Privacy Policy
- About Us
- Contact
- © 2011-2024 CaniDev