collapse collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 219
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: AJAX Chat Users Online  (Read 19389 times)

0 Members and 2 Guests are viewing this topic.

Offline mrtrc266

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Male
    • Monsters Mansion
  • SMF Version: 2 RC3
  • SP Version: 2.3.1
AJAX Chat Users Online
« on: June 09, 2009, 02:43:19 PM »
I have no idea what I'm doing and this is probably toatlly wrong but I've seemed to get a list of users in chat working in Simple Portal.

Only thing I'm would like to do now is get the list to show in the same way that the Users Online Show.

I have the Dot next to "Users In Chat"

2 things I need help with.

1. Need the [user] icon next to each user in chat
2. Need the users names (link) indented


Here code that is in the SSI.php
Code: [Select]
function ssi_chatOnline($output_method = 'echo')
{
global $db_prefix, $scripturl, $txt;

$users = array();
$userIDs = array();
$result = db_query("SELECT userID
FROM ${db_prefix}ajaxchat_online WHERE NOW() <= DATE_ADD(dateTime, interval 2 MINUTE)
", __FILE__, __LINE__);
while($row = mysql_fetch_assoc($result)) {
array_push($userIDs, $row['userID']);
}
mysql_free_result($result);

$users['IDs'] = array_unique($userIDs);
$users['links'] = array();
if (count($users['IDs']) > 0){
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($users['IDs'] as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);

$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != ""){
$link.= '" style="color: ' . $row['onlineColor'];
}
$link.= '">' . $row['realName'] . '</a>';
    array_push($users['links'], $link);
}
mysql_free_result($result);
}
if ($output_method != 'echo')
return $users;
else{
if (count($users['links']) == 0 )
  echo $txt['chat_no_user'];
elseif (count($users['links']) == 1 )
  echo '1' . $txt['chat_aUser']. ':<br />', implode($users['links']);
else
  echo count($users['links']). $txt['chat_users']. ':<br />', implode('<br />', $users['links']);
}
}

Edit to SPortal1-1.php
Found
Code: [Select]
echo '
</ul>
<br />
<div class="sp_fullwidth sp_center">', $txt['error_sp_no_online'], '</div>';
}
Added After
Code: [Select]
echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ', ssi_chatOnline(),'</li>
</ul>';

See 2 pics for better example of what I'm trying to accomplish

1st pic is the current result
2nd pic is how I'd like it

Thanks in advance for any help.
« Last Edit: June 12, 2009, 12:52:09 PM by mrtrc266 »

Offline mrtrc266

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Male
    • Monsters Mansion
  • SMF Version: 2 RC3
  • SP Version: 2.3.1
Re: AJAX Chat Users Online
« Reply #1 on: June 12, 2009, 11:32:00 AM »
48 hr Bump ;D

Does anyone have any ideas on this?

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: AJAX Chat Users Online
« Reply #2 on: June 12, 2009, 12:25:40 PM »
You know, there is a much easier way to do this.

The who's online lists generates all users and what areas they are in. Simply write a script that puts all users that are using "?action=chat" into a list, and then show it on a block.

Offline mrtrc266

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Male
    • Monsters Mansion
  • SMF Version: 2 RC3
  • SP Version: 2.3.1
Re: AJAX Chat Users Online
« Reply #3 on: June 12, 2009, 12:33:45 PM »
You know, there is a much easier way to do this.

The who's online lists generates all users and what areas they are in. Simply write a script that puts all users that are using "?action=chat" into a list, and then show it on a block.

Me? Write a script? LOL I wish I knew how.

The chat is not an action AJAX Chat is more of a stand alone Chat Room Intergrated into SMF the URL looks like this

www.mysite/chat/index.php

I almost have it...just need the user links indented and the pics to show up. Thanks though.

Offline Eliana Tamerin

  • Comrade
  • *
  • Posts: 2889
  • Gender: Female
  • SMF Version: 2 RC2
  • SP Version: 2.3.2
Re: AJAX Chat Users Online
« Reply #4 on: June 12, 2009, 04:20:53 PM »
The reason why that's more difficult, Chris, is that the AJAX Chat is an external program (which just happens to nab SMF's user database for permissions), and SMF can't track it. AJAX chat tracks its own users, whether participating in the chatroom or shoutbox versions, and can spit back that list on request, which is what the AJAX Chat Integration mod does.
Ms. Eliana Tamerin

It should be painfully obvious by now that I don't respond to support PMs. Don't send me PMs for support. They will be ignored and deleted, post on the Support Boards to get support.

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: AJAX Chat Users Online
« Reply #5 on: June 12, 2009, 06:23:27 PM »
Ahhh, I see now. I was thinking of a different type of integration.

Offline mrtrc266

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Male
    • Monsters Mansion
  • SMF Version: 2 RC3
  • SP Version: 2.3.1
Re: AJAX Chat Users Online
« Reply #6 on: June 13, 2009, 02:25:29 AM »
The reason why that's more difficult, Chris, is that the AJAX Chat is an external program (which just happens to nab SMF's user database for permissions), and SMF can't track it. AJAX chat tracks its own users, whether participating in the chatroom or shoutbox versions, and can spit back that list on request, which is what the AJAX Chat Integration mod does.

Would you know how the get the "user" pics to show next to the user links and get them inline with the other "users online?"

As always any help is greatly appreciated.

As mentioned I have it 98%....I would just like it to appear like in the second pic

Offline Hannilein

  • Semi Newbie
  • *
  • Posts: 14
  • Gender: Male
    • Homepage
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: AJAX Chat Users Online
« Reply #7 on: June 15, 2009, 07:03:43 AM »
I use the following code in a custom PHP block to show who is online in the AJAX Chat (please adapt the german text and the "<linktoyourforum>" part to your needs):

Code: [Select]
global $db_prefix, $user_info, $context, $scripturl, $modSettings, $txt;

$block_parameters = array();

if ($return_parameters)
return $block_parameters;

//users in chat
if (!WIRELESS)
    {
$userIDs = chatOnlineUsers();
$context['chat_links'] = array();
if (count($userIDs) > 0)
        {
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($userIDs as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);

$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
    $name = $row['realName'];
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != "")
                {
$link.= '" style="color: ' . $row['onlineColor'];
    }
$link.= '">' . $row['realName'] . '</a>';
    array_push($context['chat_links'], $link);
}
mysql_free_result($result);
}
//set the flag true for home page
$context['chat_isHome'] = true;
}

// users in chat
if (isset($context['chat_links']))
    {
if (count($context['chat_links']) == 0 )
{
// nobody is in the chat
        echo '<ul class="sp_list">
           <li>', sp_embed_image('dot'), ' Es ist niemand im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>.
</ul>';
        }
else
{
// show users who are in the chat
            echo '<ul class="sp_list">
           <li>', sp_embed_image('dot'), ' Zur Zeit im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>:
</ul>';

    echo '<ul class="sp_list">';

    foreach ($context['chat_links'] as $user)
        echo '<li class="sp_list_indent">', sp_embed_image('user'), ' ', $user, '</li>';

echo '</ul>';
}

    }




Regards,
Dirk

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: AJAX Chat Users Online
« Reply #8 on: July 05, 2009, 06:55:30 PM »
I use the following code in a custom PHP block to show who is online in the AJAX Chat (please adapt the german text and the "<linktoyourforum>" part to your needs):

Code: [Select]
global $db_prefix, $user_info, $context, $scripturl, $modSettings, $txt;

$block_parameters = array();

if ($return_parameters)
return $block_parameters;

//users in chat
if (!WIRELESS)
    {
$userIDs = chatOnlineUsers();
$context['chat_links'] = array();
if (count($userIDs) > 0)
        {
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($userIDs as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);

$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
    $name = $row['realName'];
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != "")
                {
$link.= '" style="color: ' . $row['onlineColor'];
    }
$link.= '">' . $row['realName'] . '</a>';
    array_push($context['chat_links'], $link);
}
mysql_free_result($result);
}
//set the flag true for home page
$context['chat_isHome'] = true;
}

// users in chat
if (isset($context['chat_links']))
    {
if (count($context['chat_links']) == 0 )
{
// nobody is in the chat
        echo '<ul class="sp_list">
           <li>', sp_embed_image('dot'), ' Es ist niemand im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>.
</ul>';
        }
else
{
// show users who are in the chat
            echo '<ul class="sp_list">
           <li>', sp_embed_image('dot'), ' Zur Zeit im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>:
</ul>';

    echo '<ul class="sp_list">';

    foreach ($context['chat_links'] as $user)
        echo '<li class="sp_list_indent">', sp_embed_image('user'), ' ', $user, '</li>';

echo '</ul>';
}

    }




Regards,
Dirk

Would it be possible for a translation of the German please. I would like to give this a trial for my portal.
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

Offline thehj

  • Semi Newbie
  • *
  • Posts: 21
  • SMF Version: 2 RC1-1
  • SP Version: 2.2.2
Re: AJAX Chat Users Online
« Reply #9 on: July 07, 2009, 01:52:12 PM »
Hannilein, thanks, but i think the script is not working for online users... i mean, when nobody's in the chat, it's working, but if someone is chatting, it shows some errors!

i guess making mrtrc266's idea as a mod would be much neater, i mean, why create another block when you can integrate it in the same block?

Offline Raji

  • Full Member
  • ***
  • Posts: 102
  • Gender: Female
    • Baaskani Diwwan
  • SMF Version: 2.0.1
  • SP Version: 2.3.4
Re: AJAX Chat Users Online
« Reply #10 on: August 05, 2009, 01:24:24 AM »
I use the following code in a custom PHP block to show who is online in the AJAX Chat (please adapt the german text and the "<linktoyourforum>" part to your needs):

Code: [Select]
global $db_prefix, $user_info, $context, $scripturl, $modSettings, $txt;

$block_parameters = array();

if ($return_parameters)
return $block_parameters;

//users in chat
if (!WIRELESS)
    {
$userIDs = chatOnlineUsers();
$context['chat_links'] = array();
if (count($userIDs) > 0)
        {
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($userIDs as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);

$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
    $name = $row['realName'];
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != "")
                {
$link.= '" style="color: ' . $row['onlineColor'];
    }
$link.= '">' . $row['realName'] . '</a>';
    array_push($context['chat_links'], $link);
}
mysql_free_result($result);
}
//set the flag true for home page
$context['chat_isHome'] = true;
}

// users in chat
if (isset($context['chat_links']))
    {
if (count($context['chat_links']) == 0 )
{
// nobody is in the chat
        echo '<ul class="sp_list">
           <li>', sp_embed_image('dot'), ' Es ist niemand im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>.
</ul>';
        }
else
{
// show users who are in the chat
            echo '<ul class="sp_list">
           <li>', sp_embed_image('dot'), ' Zur Zeit im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>:
</ul>';

    echo '<ul class="sp_list">';

    foreach ($context['chat_links'] as $user)
        echo '<li class="sp_list_indent">', sp_embed_image('user'), ' ', $user, '</li>';

echo '</ul>';
}

    }




Regards,
Dirk

Would it be possible for a translation of the German please. I would like to give this a trial for my portal.

It worked fine at my site www.baask.com/diwwan

Offline mrtrc266

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Male
    • Monsters Mansion
  • SMF Version: 2 RC3
  • SP Version: 2.3.1
Re: AJAX Chat Users Online
« Reply #11 on: August 06, 2009, 05:16:04 PM »
Here we go, Hunter (AJAX Chat Intergration Mod Author) made a little add-on that has it exaclty like I was trying to explain.

Thank you!

Offline primetime

  • Semi Newbie
  • *
  • Posts: 8
  • SMF Version: 2 RC1
  • SP Version: 2.2.2
Re: AJAX Chat Users Online
« Reply #12 on: September 01, 2009, 09:03:31 AM »
Here we go, Hunter (AJAX Chat Intergration Mod Author) made a little add-on that has it exaclty like I was trying to explain.

Thank you!

I installed this add-on and got the following error..
Fatal error: Call to undefined function ssi_chatonline() in /home/reefersr/public_html/dev/Sources/SPortal2.php on line 798

I am using ajax 3.0 and SP 2.2.2. Does chat 3.2 need to be installed?

Offline mrtrc266

  • Jr. Member
  • **
  • Posts: 91
  • Gender: Male
    • Monsters Mansion
  • SMF Version: 2 RC3
  • SP Version: 2.3.1
Re: AJAX Chat Users Online
« Reply #13 on: April 12, 2010, 06:13:04 PM »
Tested with SP 2.3.2 and SMF RC3 (modified from Hunters Addon)



Find /Sources/PortalBlocks.php

Code: [Select]
}

function sp_boardStats($parameters, $id, $return_parameters = false)

Replace with
Code: [Select]
//AJAX Chat Users in Chat
$users = ssi_chatOnline('SP');
$count = count($users['links']);
echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ',$txt['chat_users'], ': ', $count, '</li>
</ul>';
if ($count >= 1 ){
  echo '
<ul class="sp_list">';
if ($count == 1 )
  echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', implode($users['links']), '</li>';
else
foreach ($users['links'] as $link)
  echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', $link, '</li>';
  echo '
</ul>';
}
}

function sp_boardStats($parameters, $id, $return_parameters = false)

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: AJAX Chat Users Online
« Reply #14 on: April 13, 2010, 06:26:11 AM »
Hurrah

It works. Can see who is in chat on the block.

One for the next version maybe?
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

Offline Raji

  • Full Member
  • ***
  • Posts: 102
  • Gender: Female
    • Baaskani Diwwan
  • SMF Version: 2.0.1
  • SP Version: 2.3.4
Re: AJAX Chat Users Online
« Reply #15 on: May 13, 2010, 01:50:58 AM »
Tested with SP 2.3.2 and SMF RC3 (modified from Hunters Addon)



Find /Sources/PortalBlocks.php

Code: [Select]
}

function sp_boardStats($parameters, $id, $return_parameters = false)

Replace with
Code: [Select]
//AJAX Chat Users in Chat
$users = ssi_chatOnline('SP');
$count = count($users['links']);
echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ',$txt['chat_users'], ': ', $count, '</li>
</ul>';
if ($count >= 1 ){
  echo '
<ul class="sp_list">';
if ($count == 1 )
  echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', implode($users['links']), '</li>';
else
foreach ($users['links'] as $link)
  echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', $link, '</li>';
  echo '
</ul>';
}
}

function sp_boardStats($parameters, $id, $return_parameters = false)

Thanks a lot. it worked for me too :)

Offline HML

  • Newbie
  • Posts: 2
  • SMF Version: None
  • SP Version: None
Re: AJAX Chat Users Online
« Reply #16 on: March 17, 2011, 02:46:27 PM »
Does anyone know if this works with SMF RC5, too?

Offline MFCSteve

  • Newbie
  • Posts: 3
  • SMF Version: 1.1.13
  • SP Version: 2.3.3
Re: AJAX Chat Users Online
« Reply #17 on: March 24, 2011, 08:48:54 PM »
I have got this working at http://squeeze.follyball.co.uk/index.php but it will only show up on the Index page. Is there any way to get it to show on every page?

Steve

Offline HML

  • Newbie
  • Posts: 2
  • SMF Version: None
  • SP Version: None
Re: AJAX Chat Users Online
« Reply #18 on: March 27, 2011, 02:40:02 AM »
Does anyone know if this works with SMF RC5, too?

Quoting myself, but anyhow... I tried it, and the answer is yes.