X7 Chat Support Board
Welcome, Guest. Please login or register.
July 31, 2010, 07:48:22 PM

Login with username, password and session length
Search:     Advanced search
X7 Chat Version 3.0.0 Alpha 2 is now available (http://x7chat.com/support_forum/index.php?topic=3198.msg11497#new).
13036 Posts in 3760 Topics by 66536 Members
Latest Member: usheeenkogon
* Home Help Search Login Register
+  X7 Chat Support Board
|-+  X7 Chat Mods
| |-+  Mod Requests
| | |-+  Online Users Chat Mod IS HERE!
« previous next »
Pages: 1 [2] 3 Reply Send this topic Print
Author Topic: Online Users Chat Mod IS HERE!  (Read 14284 times)
Joseph
Member
*
Offline Offline

Posts: 19


View Profile
« Reply #15 on: October 28, 2006, 12:10:45 PM »
Reply with quote

Of course I can i just used the code that was provided in this post



it's really simple(will add in a few mins)

Code:
<html><body><table width='25%'bgcolor="C0C0C0" align=center border=3 valign=top cellpadding=2 cellspacing='0'>
<tr><td width='25%' align=center>"In Chat"</td><td width='25%' align=center>"Room"</td></tr>
<?
//connect to mysql
//change localhost, username and password to your mySQL username and password
mysql_connect("localhost","username of database","Password for username");

//select which database, change DBname
mysql_select_db("your database name");

//select the table, should be right if you didn't change the prefix in the data base
$result = mysql_query("select * from x7chat2_online");



//grab all the content
while($r=mysql_fetch_array($result))
{

//modify these to match your mysql table columns that you want to display

$usersonline=$r["name"];
$room=$r["room"];

//display the row
echo "<tr><td width='25%' align=center>$usersonline<br></td><td width='25%' align=center>$room<br>";


}
?>

</td></tr></table><br></body>



</html>
« Last Edit: October 28, 2006, 01:55:26 PM by Joseph » Report to moderator   Logged
drexful
Member
*
Offline Offline

Posts: 8


View Profile
« Reply #16 on: October 28, 2006, 06:07:51 PM »
Reply with quote

Thanks for posting the code. I have been playing with it since this morning and cannot get the code to "update" users. It shows users on the list even after they've been logged out for hours.. It looks like you are using the same code I am.. I think we need to look at online.php or something.

I think this has something to do with connection time -30??


Please help us OREO...


Report to moderator   Logged
Joseph
Member
*
Offline Offline

Posts: 19


View Profile
« Reply #17 on: October 28, 2006, 06:20:35 PM »
Reply with quote

Mine updates fine. try checking into your expire settings
Report to moderator   Logged
drexful
Member
*
Offline Offline

Posts: 8


View Profile
« Reply #18 on: October 29, 2006, 03:27:32 PM »
Reply with quote

What expire settings are you talking about?

My settings are below..

Max idle time - 30 seconds

Messages Expire - 0

Rooms Expire - 30 minutes

Guest Accounts Expire - 1 munite (disabled in ACP)


The code may *sort of* work, but it is reading the wrong part of the SQL table. It should not be reading "user"...

Take a look at online.php

Quote
   // Get the number of people online
      $exptime = time()-30;
      $query = $db->DoQuery("SELECT * FROM {$prefix}online WHERE invisible<>'1' AND time>'$exptime'");
      while($row = $db->Do_Fetch_Row($query))
         $number++;

I am integrated with phpBB.. I wonder if the cookie is messing things up?


What I'd really like to do is have code like this.. I currently use FlashChat for my chat system, but do not care for flash systems that much. BUT, they do have a killer "who's online" file that I can integrate with my forums.. It shows the name of the room, how may users are in the room, and which users are in the room. It uses javascript in the code. I am really not a coder.. I have a "mess around and keep trying 'til it works" method Smiley If you want to call it that. I know very little PHP and JS.. I do know HTML fairly well. Check this out if you can and tell me what you think. It is a killer way to show peeps online cool

I've attached two images below for reference to the Flashchat files.

Code for info.php
Quote
<?php

   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");


/**
If this file is not in the FlashChat root folder, then change this
path to the location of the inc/common.php file.
*/
require_once('inc/common.php');

ChatServer::purgeExpired();

/**
Retrieves the number of users who are chatting in any room.
Leave the $room parameter empty to return the number of users in all room.
*/
function numusers( $room = "" )
{
   if($room) {
      $stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND userid <> ? AND roomid=?");
      $rs = $stmt->process(SPY_USERID, $room);
   } else {
      $stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections,{$GLOBALS['fc_config']['db']['pref']}rooms
                       WHERE userid IS NOT NULL AND userid <> ? AND ispublic IS NOT NULL
                       AND {$GLOBALS['fc_config']['db']['pref']}connections.roomid = {$GLOBALS['fc_config']['db']['pref']}rooms.id");
      $rs = $stmt->process(SPY_USERID);
   }

   $rec = $rs->next();

   return $rec?$rec['numb']:0;
}

/**
Retrieves a list of the users (by login ID) who are in $room.
Leave the $room parameter empty to return a list of all users in all rooms.
*/
function usersinroom( $room = "" )
{
   $list = array();

   if($room) {
      $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND userid <> ? AND roomid=?");
      $rs = $stmt->process(SPY_USERID, $room);
   } else {
      $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND userid <> ?");
      $rs = $stmt->process(SPY_USERID);
   }

   while($rec = $rs->next())
   {
      $usr = ChatServer::getUser($rec['userid']);
      if($usr == null && $GLOBALS['fc_config']['enableBots']) $usr = $GLOBALS['fc_config']['bot']->getUser($rec['userid']);
      $list[] = array_merge($usr, $rec);
   }

   return $list;
}

/**
Retrieves a list of all available rooms, as an array.
*/
function roomlist()
{
   $list = array();

   // populate $list with the names of all available rooms
   $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NOT NULL order by ispermanent");
   $rs = $stmt->process();

   while($rec = $rs->next()) $list[] = $rec;

   //result will be an array of arrays like ('id' => <room id>, 'updated' = <timestamp>, 'created' => <timestamp>, 'name' => <room name>, 'ispublic' => <public flag>, 'ispermanent' => <autoclose flag>)
   return $list;
}


$rooms = roomlist();
$roomnumb = sizeof($rooms);
$usernumb = numusers();
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Who's in the chat?</title>
<meta http-equiv=Content-Type content="text/html;  charset=UTF-8">
<style type="text/css">
<!--
.normal {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   font-weight: normal;
}
A {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #0000FF;
}
A:hover {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #FF0000;
}
-->
</style>
</head>
   <body>
      <center>
      <p class=normal>There are <?php echo numusers()?> users in <?php echo $roomnumb?> rooms.</p>
      <?php if($roomnumb) { ?>
         <table border="1" cellpadding="1" class="normal">
            <tr>
               <th>ID</th>
               <th>Name</th>
               <th>Count</th>
               <th>Users</th>
            </tr>
            <?php foreach($rooms as $room) { ?>
               <tr>
                  <td><?php echo $room['id']?></td>
                  <td><?php echo $room['name']?></td>
                  <td><?php echo numusers($room['id'])?></td>
                  <td><?php

                  $users = usersinroom($room['id']);

                  foreach( $users as $user ) {
                     echo $user['login'] . "<br>";
                  }

                  ?> </td>
               </tr>
            <?php } ?>
         </table>
      <?php } ?>

      <p><a href="javascript:window.close()">Close</a></p>
      </center>
   </body>
</html>

Code for info_embedded.php (What I use on my forum index)
Quote
<?php

   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");


/**
If this file is not in the FlashChat root folder, then change this
path to the location of the inc/common.php file.
*/
require_once('inc/common.php');

ChatServer::purgeExpired();

/**
Retrieves the number of users who are chatting in any room.
Leave the $room parameter empty to return the number of users in all room.
*/
function numusers( $room = "" )
{
   if($room) {
      $stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND userid <> ? AND roomid=?");
      $rs = $stmt->process(SPY_USERID, $room);
   } else {
      $stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections,{$GLOBALS['fc_config']['db']['pref']}rooms
                       WHERE userid IS NOT NULL AND userid <> ? AND ispublic IS NOT NULL
                       AND {$GLOBALS['fc_config']['db']['pref']}connections.roomid = {$GLOBALS['fc_config']['db']['pref']}rooms.id");
      $rs = $stmt->process(SPY_USERID);
   }

   $rec = $rs->next();

   return $rec?$rec['numb']:0;
}

/**
Retrieves a list of the users (by login ID) who are in $room.
Leave the $room parameter empty to return a list of all users in all rooms.
*/
function usersinroom( $room = "" )
{
   $list = array();

   if($room) {
      $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND userid <> ? AND roomid=?");
      $rs = $stmt->process(SPY_USERID, $room);
   } else {
      $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND userid <> ?");
      $rs = $stmt->process(SPY_USERID);
   }

   while($rec = $rs->next())
   {
      $usr = ChatServer::getUser($rec['userid']);
      if($usr == null && $GLOBALS['fc_config']['enableBots']) $usr = $GLOBALS['fc_config']['bot']->getUser($rec['userid']);
      $list[] = array_merge($usr, $rec);
   }

   return $list;
}

/**
Retrieves a list of all available rooms, as an array.
*/
function roomlist()
{
   $list = array();

   // populate $list with the names of all available rooms
   $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NOT NULL order by ispermanent");
   $rs = $stmt->process();

   while($rec = $rs->next()) $list[] = $rec;

   //result will be an array of arrays like ('id' => <room id>, 'updated' = <timestamp>, 'created' => <timestamp>, 'name' => <room name>, 'ispublic' => <public flag>, 'ispermanent' => <autoclose flag>)
   return $list;
}


$rooms = roomlist();
$roomnumb = sizeof($rooms);
$usernumb = numusers();
?>
<html>
<head>
<title>Who's in the chat?</title>
<meta http-equiv=Content-Type content="text/html;  charset=UTF-8">
<style type="text/css">
<!--

body { background-color: transparent; margin: 0; padding: 0; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; font-size: 10px;}
....normal {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 10px;
   font-weight: normal;
   margin: 0; padding: 0;
        text-align: center;
}

#roomList { margin: 0; padding: 0; }
#roomList a { color: black; text-decoration: none; } #roomList a:hover { text-decoration: underline; }
....userList { margin-left: 7px; margin-right: 0; margin-bottom: 0; margin-top: 0;  padding: 0; }

-->
</style>
<script type="text/javascript">
function toggleUserList(id) {
   if (l = document.getElementById(id)) {
      if (l.style.display == '' || l.style.display == 'block') l.style.display = 'none';
      else l.style.display = 'block';
   }
   return false;
}

</script>
</head>
<body>
<p class=normal><?php echo $usernumb ?> user<?php if ($usernumb != 1) echo "s" ?> in <?php echo $roomnumb ?> room<?php if ($roomnumb != 1) echo "s"; ?>.</p>
<ul id="roomList">
<?php if($roomnumb) { ?>
      <?php foreach($rooms as $room) { ?>
            <li><strong><a href="#" onclick="javascript:toggleUserList('room_<?php echo $room['id']?>')"><?php echo $room['name']?> (<?php echo numusers($room['id']) ?>)</a></strong>
            <?php

               $users = usersinroom($room['id']);
                                        if ($users) {
                                          echo "<ul class=\"userList\" id=\"room_".$room['id']."\">";
                                          foreach( $users as $user ) {
                   echo "<li>".$user['login'] . "</li>";
                 }
                                          echo "</ul>";
                                        }

            ?> </li>
      <?php } ?>
<?php } ?>
</ul>

</body>
</html>





« Last Edit: October 29, 2006, 03:29:29 PM by drexful » Report to moderator   Logged
drexful
Member
*
Offline Offline

Posts: 8


View Profile
« Reply #19 on: October 29, 2006, 03:31:20 PM »
Reply with quote

ok for some reason my pics aren't showing up.

let's try again
Report to moderator   Logged
Frank
Guest


Email
« Reply #20 on: November 06, 2006, 04:30:55 AM »
Reply with quote

This works great! Thanx very much. But would there also be a way to show the avatar of the user next to the name? This would really make it perfect. Thanx in advance.

Frank
Report to moderator   Logged
mrandall131
Member
*
Offline Offline

Posts: 9


View Profile Email
« Reply #21 on: November 06, 2006, 05:46:30 AM »
Reply with quote

I don't suppose anyone is running this that's using MKPortal?
Report to moderator   Logged
Frank
Member
*
Offline Offline

Posts: 1


View Profile
« Reply #22 on: November 06, 2006, 05:58:50 AM »
Reply with quote

I don't suppose anyone is running this that's using MKPortal?

What do you mean exactly, I am not using any portal. I'm just referring to the avatar that can be uploaded in X7Chat (like it is displayed in a user's profile). I woul like this avatar to also be displayed in the "Online Users Chat Mod".
Report to moderator   Logged
mrandall131
Member
*
Offline Offline

Posts: 9


View Profile Email
« Reply #23 on: November 07, 2006, 06:28:22 AM »
Reply with quote

I am using MKPortal for the "front end" to my site.  What I would like to do is show the users in the chat room in one of it's blocks.  I took the code from here and will be adding it to the who.template.php for users chatting (testing it now), but I can't seem to figure out how to do it in a block in the portal.
Report to moderator   Logged
allen81
Member
*
Offline Offline

Posts: 12


View Profile
« Reply #24 on: November 13, 2006, 08:57:23 PM »
Reply with quote

Can anyone tell me what file to put the code in so it will work sucessfully?
Report to moderator   Logged
madfiddler
Member
*
Offline Offline

Posts: 7


View Profile Email
« Reply #25 on: December 27, 2006, 08:57:46 AM »
Reply with quote

I'm not having much luck with this, the usersonline table in mysql appears to stay empty even when there are people in chat. I'm using mkportal and smf btw
« Last Edit: December 27, 2006, 09:32:43 AM by madfiddler » Report to moderator   Logged
Rep
Member
*
Offline Offline

Posts: 38


View Profile Email
« Reply #26 on: January 15, 2007, 07:56:36 AM »
Reply with quote

I have not changed anything concerning my database and have not renamed fields etc.  When I upload the script, the names of people in chat is not listed.  Do I have to do something with the following? Do I have to identify the room in some way?



 //modify these to match your mysql table columns that you want to display

   $usersonline=$r["usersonline"];
   $room=$r["room"];
Report to moderator   Logged
sincereti
Guest


Email
« Reply #27 on: April 17, 2007, 05:02:22 PM »
Reply with quote

hey! how did you get that web site online!
Report to moderator   Logged
Leader_Tom
Member
*
Offline Offline

Posts: 1


View Profile Email
« Reply #28 on: May 30, 2007, 05:13:18 PM »
Reply with quote

Hey how can you host a chat on your website called arcadebite.4t.com  for free?  if anyone knows how email me at Arcadebite.4t.org@gmail.com ok thanks  afro[ [/glow][/s]
Report to moderator   Logged
Dazzy
Guest


Email
« Reply #29 on: July 13, 2007, 08:36:20 AM »
Reply with quote

Hey all

I have this working but the list doesnt update when someone logs off, my expire settings are the same as posted above, any ideas?

Many thanks
Report to moderator   Logged
Pages: 1 [2] 3 Reply Send this topic Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.204 seconds with 18 queries.