Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Forums and "Who's Online?"

Is there any way to add simple Who's online table on the bottom of the forums? Like in Invision Power Boards? Example: http://forums.invisionpower.com/

Things marked in red are things that I would like to have on my forums:
sumowski.com/syf/interesting.JPG


I've seen that in Advanced Forum Mod for V6, so it is possible in PHP-Fusion.
add a l-ctr panel with codes like this:

if(eregi("forum",$_SERVER["REQUEST_URI"])) {
//online users panel's codes here
}


OR modify forum index, viewforum, viewthread.php
Wouldn't this be safer?
if(eregi("\/forum\/index.php",$_SERVER["REQUEST_URI"])) {
//online users panel's codes here
}

People searching for "forum" with our search engine would also get that statistics page and we only need to display stats on it's index.
Ok I get it but it ain't working

This is the online panel code:
CodeDownload  
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright © 2002 - 2007 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: online_users_panel.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }
   
$result = dbquery("SELECT * FROM ".DB_ONLINE." WHERE online_user=".($userdata['user_level'] != 0 ? "'".$userdata['user_id']."'" : "'0' AND online_ip='".USER_IP."'"));
if (dbrows($result)) {
   $result = dbquery("UPDATE ".DB_ONLINE." SET online_lastactive='".time()."' WHERE online_user=".($userdata['user_level'] != 0 ? "'".$userdata['user_id']."'" : "'0' AND online_ip='".USER_IP."'")."");
} else {
   $result = dbquery("INSERT INTO ".DB_ONLINE." (online_user, online_ip, online_lastactive) VALUES ('".($userdata['user_level'] != 0 ? $userdata['user_id'] : "0")."', '".USER_IP."', '".time()."')");
}
$result = dbquery("DELETE FROM ".DB_ONLINE." WHERE online_lastactive<".(time()-60)."");

openside($locale['global_010']);
$result = dbquery(
   "SELECT ton.*, tu.user_id,user_name FROM ".DB_ONLINE." ton
   LEFT JOIN ".DB_USERS." tu ON ton.online_user=tu.user_id"
);
$guests = 0; $members = array();
while ($data = dbarray($result)) {
   if ($data['online_user'] == "0") {
      $guests++;
   } else {
      array_push($members, array($data['user_id'], $data['user_name']));
   }
}
echo THEME_BULLET." ".$locale['global_011'].": ".$guests."<br /><br />\n";
echo THEME_BULLET." ".$locale['global_012'].": ".count($members)."<br />\n";
if (count($members)) {
   $i = 1;
   while (list($key, $member) = each($members)) {
      echo "<a href='".BASEDIR."profile.php?lookup=".$member[0]."' class='side'>".$member[1]."</a>";
      if ($i != count($members)) { echo ",\n"; } else { echo "<br />\n"; }
      $i++;
   }
}
echo "<br />\n".THEME_BULLET." ".$locale['global_014'].": ".number_format(dbcount("(user_id)", DB_USERS, "user_status<='1'"))."<br />\n";
if (iADMIN && checkrights("M") && $settings['admin_activation'] == "1") {
   echo THEME_BULLET." <a href='".ADMIN."members.php".$aidlink."&amp;status=2' class='side'>".$locale['global_015']."</a>";
   echo ": ".dbcount("(user_id)", DB_USERS, "user_status='2'")."<br />\n";
}
$data = dbarray(dbquery("SELECT user_id,user_name FROM ".DB_USERS." WHERE user_status='0' ORDER BY user_joined DESC LIMIT 0,1"));
echo THEME_BULLET." ".$locale['global_016'].": <a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' class='side'>".$data['user_name']."</a>\n";
closeside();
?>



So I did this:
CodeDownload  
  echo "if(eregi("\/forum\/index.php",$_SERVER["REQUEST_URI"])) 
{
if (!defined("IN_FUSION")) { die("Access Denied"); }
   
$result = dbquery("SELECT * FROM ".DB_ONLINE." WHERE online_user=".($userdata['user_level'] != 0 ? "'".$userdata['user_id']."'" : "'0' AND online_ip='".USER_IP."'"));
if (dbrows($result)) {
   $result = dbquery("UPDATE ".DB_ONLINE." SET online_lastactive='".time()."' WHERE online_user=".($userdata['user_level'] != 0 ? "'".$userdata['user_id']."'" : "'0' AND online_ip='".USER_IP."'")."");
} else {
   $result = dbquery("INSERT INTO ".DB_ONLINE." (online_user, online_ip, online_lastactive) VALUES ('".($userdata['user_level'] != 0 ? $userdata['user_id'] : "0")."', '".USER_IP."', '".time()."')");
}
$result = dbquery("DELETE FROM ".DB_ONLINE." WHERE online_lastactive<".(time()-60)."");


$result = dbquery(
   "SELECT ton.*, tu.user_id,user_name FROM ".DB_ONLINE." ton
   LEFT JOIN ".DB_USERS." tu ON ton.online_user=tu.user_id"
);
$guests = 0; $members = array();
while ($data = dbarray($result)) {
   if ($data['online_user'] == "0") {
      $guests++;
   } else {
      array_push($members, array($data['user_id'], $data['user_name']));
   }
}
echo THEME_BULLET." ".$locale['global_011'].": ".$guests."<br /><br />\n";
echo THEME_BULLET." ".$locale['global_012'].": ".count($members)."<br />\n";
if (count($members)) {
   $i = 1;
   while (list($key, $member) = each($members)) {
      echo "<a href='".BASEDIR."profile.php?lookup=".$member[0]."' class='side'>".$member[1]."</a>";
      if ($i != count($members)) { echo ",\n"; } else { echo "<br />\n"; }
      $i++;
   }
}
echo "<br />\n".THEME_BULLET." ".$locale['global_014'].": ".number_format(dbcount("(user_id)", DB_USERS, "user_status<='1'"))."<br />\n";
if (iADMIN && checkrights("M") && $settings['admin_activation'] == "1") {
   echo THEME_BULLET." <a href='".ADMIN."members.php".$aidlink."&amp;status=2' class='side'>".$locale['global_015']."</a>";
   echo ": ".dbcount("(user_id)", DB_USERS, "user_status='2'")."<br />\n";
}
$data = dbarray(dbquery("SELECT user_id,user_name FROM ".DB_USERS." WHERE user_status='0' ORDER BY user_joined DESC LIMIT 0,1"));
echo THEME_BULLET." ".$locale['global_016'].": <a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' class='side'>".$data['user_name']."</a>\n";
}



And it doesn't work. :P The panel is enabled (just in case anyone asks). I've removed the openside, closeside lines because I don't want this to be visible as a panel.

Quote

kneekoo wrote:
Wouldn't this be safer?
if(eregi("\/forum\/index.php",$_SERVER["REQUEST_URI"])) {
//online users panel's codes here
}

People searching for "forum" with our search engine would also get that statistics page and we only need to display stats on it's index.


that's right, but at core, there's no file which has "forum" word inside except forum, and the code i gave is for whole forum, not only for index, i thought less name checking would be a very little bit faster :) , but your mod guarantees the user's inside forum/index.php yes :)
Ok it does work now, but it doesn't really look like it's verticallly placed, that's what I wanted.

edit:
It's like this:
sumowski.com/syf/fnsgsdui1.JPG

And I would like it to be like this:
sumowski.com/syf/fnsgsdui2.JPG
the remanis is just html edit , can you give a sample URL ?
at your wish, it'll kill the design, consider that there're 25 online users, that sure won't look good,

try this, it'll be something like this, but didn't tried myself though
<?php
if(strpos(dirname($_SERVER['REQUEST_URI']), "forum") !== false) {
opentable($locale['global_010']);
$result = dbquery("SELECT * FROM ".DB_ONLINE." WHERE online_user=".($userdata['user_level'] != 0 ? "'".$userdata['user_id']."'" : "'0' AND online_ip='".USER_IP."'"));
if (dbrows($result)) {
$result = dbquery("UPDATE ".DB_ONLINE." SET online_lastactive='".time()."' WHERE online_user=".($userdata['user_level'] != 0 ? "'".$userdata['user_id']."'" : "'0' AND online_ip='".USER_IP."'")."");
} else {
$result = dbquery("INSERT INTO ".DB_ONLINE." (online_user, online_ip, online_lastactive) VALUES ('".($userdata['user_level'] != 0 ? $userdata['user_id'] : "0")."', '".USER_IP."', '".time()."')");
}
$result = dbquery("DELETE FROM ".DB_ONLINE." WHERE online_lastactive<".(time()-60)."");

$result = dbquery(
"SELECT ton.*, tu.user_id,user_name FROM ".DB_ONLINE." ton
LEFT JOIN ".DB_USERS." tu ON ton.online_user=tu.user_id"
);
$guests = 0; $members = array();
while ($data = dbarray($result)) {
if ($data['online_user'] == "0") {
$guests++;
} else {
array_push($members, array($data['user_id'], $data['user_name']));
}
}
$width =(iADMIN && checkrights("M") && $settings['admin_activation'] == "1")?"20%":"25%"; //if member's an admin, and has rights to adminitrate members, he'll see unactivated members, so there'll be 5 cells not 4,.
//if the php can't handle width with the line given above (lol i'm not sure), try this instead of the line above
/*
if (iADMIN && checkrights("M") && $settings['admin_activation'] == "1") { $width ='20%'; } else { $width='25%'; }
*/
echo "<table cellpadding='0' cellspacing='0'><tr>";
echo "<td width='$width'>";
echo THEME_BULLET." ".$locale['global_011'].":<br /> ".$guests."\n";
echo "</td><td width='$width'>";
echo THEME_BULLET." ".$locale['global_012'].": ".count($members)."<br />\n";
if (count($members)) {
$i = 1;
while (list($key, $member) = each($members)) {
echo "<a href='".BASEDIR."profile.php?lookup=".$member[0]."' class='side'>".$member[1]."</a>";
if ($i != count($members)) { echo ",\n"; } else { echo "<br />\n"; }
$i++;
}
}
echo "</td><td width='$width'>";
echo "\n".THEME_BULLET." ".$locale['global_014'].": ".number_format(dbcount("(user_id)", DB_USERS, "user_status<='1'"))."\n";
if (iADMIN && checkrights("M") && $settings['admin_activation'] == "1") {
echo "</td><td width='$width'>";
echo THEME_BULLET." <a href='".ADMIN."members.php".$aidlink."&amp;status=2' class='side'>".$locale['global_015']."</a>";
echo ": ".dbcount("(user_id)", DB_USERS, "user_status='2'")."\n";
}
echo "</td><td width='$width'>";
$data = dbarray(dbquery("SELECT user_id,user_name FROM ".DB_USERS." WHERE user_status='0' ORDER BY user_joined DESC LIMIT 0,1"));
echo THEME_BULLET." ".$locale['global_016'].": <a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' class='side'>".$data['user_name']."</a>\n";
echo "</td></tr></table>";
closetable();
}

?>
ok thanks, it's all ok now, but it seems like my forums got messed up, look at the categories:
sumowski.com/syf/onecatergory.JPG

after I disable the panel it doesn't fix itself lol, help?

also I nice border would be nice around the whole "who's online" panel on the bottom, border like:

<table width='200' border='1' bordercolor='#BDC5CB' bgcolor='#E8EEF1'>
<tr>
<td>&nbsp;</td>
</tr>
</table>

Quote

SoulSmasher wrote:
at your wish, it'll kill the design, consider that there're 25 online users, that sure won't look good,

try this, it'll be something like this, but didn't tried myself though


this would indeed mess up the site with more the 20 something users, I left it as it was before
you didn't add <?php and ?> , did you ?
and how was the original one ? if you disabled it (i mean deleted the code) that shoudln't be because of the codes, what are your very latest modifications ?
there was no modifications, the only thing I did was this panel AND I've moved ONE forum above the other (both in same category).

and yes I did not add the <?php and ?> because it didn't work with it.

edit:
just tried again now, with the <?php and ?> and it just doesn't work, it won't display at all

edit2:

when you move around categories and forums with arrow down or arrow up it messes up the whole forum index, I've clicked randomly on forums and cats and it fixed somehow, very wierd, I guess it's a bug?
I don't mean to hijack this thread, but my question is very similar to this one, and OP's question has been answered, so..

How would you go about the same thing, except a viewing the topic instead of on the whole forum such as:

guests viewing this topic: 6
members viewing this topic: member1, member2, member3, member4

Thanks!
Thread Information
Author
Replies
14 posts
Views
2705 times
Last Post
Last updated on 12 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: kneekoo, Arda, stranded, googlebot