View Full Version : Who's online on non-vB page (with usernames, same rules as Who's Online on forumhome)
Gary King
10 Jan 2004, 19:36
PLEASE CLICK ON THE INSTALL BUTTON IF YOU INSTALLED THIS! THANKS!
What does this hack do?
Using this hack, you can show who is currently on your forums from anywhere else on your website! The page, though, must be a PHP page.
If you want to display this information on another webpage by integrating it (which you'll probably want to ;)), just put
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
or
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
depending on the location of the online.php file
THE BELOW IS ONLY IF YOU ARE USING ONLINE.PHP
If you are using online.php, then this line of code MUST be at the top of the page!
If you don't want to show the total users online at the top of the page, though, then remove
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
and copy that to wherever you want to show the info instead (remember to surround this with PHP tags, such as:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
THE ABOVE IS ONLY IF YOU ARE USING ONLINE.PHP
Features
supports phrases! :D
option to display either usernames or a total number of registered members instead
only administrators can see users who choose to be invisible
Instructions
Download the attached online.php if you want to show invisible users to administrators, etc., or download online_external.php if you don't want to worry as much about things :), and follow these instructions:
Find
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
, change the ./vb3/ to whatever the path is to your forums directory Find
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
and change $showusernames to 1 if you want to display usernames, instead of the total number of registered members browsing
That's it! :D
Unable to add cookies, header already sent.
File: /home/indeathw/public_html/index.php
Line: 19
allthough, http://www.indeathwefall.co.uk/online.php works?!
Gary King
10 Jan 2004, 22:43
allthough, http://www.indeathwefall.co.uk/online.php works?!
Instructions updated, please check again :)
You're not going to make it in a nice little table to match the forum?
You're not going to make it in a nice little table to match the forum?
only logged in Users can show it.
-------------------
Unable to add cookies, header already sent.
File: N/A
Line: 0
--------------------
Another one with this problems?
Gary King
10 Jan 2004, 23:49
only logged in Users can show it.
-------------------
Unable to add cookies, header already sent.
File: N/A
Line: 0
--------------------
Another one with this problems?
You have to put the require_once() at the top of any file.
You have to put the require_once() at the top of any file.
thanks. will try again. :)
no, the same Problem.
but is it a must to have cookies?
there must be a simple way to get this
Members: 8 Guests: 10
nothing else!
------------------------------
@Admins
clicking for smilies brings me always to the top (#)
eva2000
11 Jan 2004, 01:08
2 bugs for me
1. i get Member instead of Members - the 's' is missing even though i have more than 1 member online
2. members online figure is incorrectly shown, i.e. on my forums there are 29-32 members online but this script shows 65 members online ? i.e. http://animeboards.com/joinwink.php
Gary King
11 Jan 2004, 01:11
no, the same Problem.
but is it a must to have cookies?
there must be a simple way to get this
Members: 8 Guests: 10
nothing else!
------------------------------
@Admins
clicking for smilies brings me always to the top (#)
Download online_external.php ;)
Gary King
11 Jan 2004, 01:12
thanks. will try again. :)
If doesn't work, use online_external.php instead :)
Gary King
11 Jan 2004, 01:26
2 bugs for me
1. i get Member instead of Members - the 's' is missing even though i have more than 1 member online
2. members online figure is incorrectly shown, i.e. on my forums there are 29-32 members online but this script shows 65 members online ? i.e. http://animeboards.com/joinwink.php
Okay, try the new files I attached :)
eva2000
11 Jan 2004, 01:26
also it would be nice to add code to check if forum is closed or not and display "forum is down for maintenance" message if closed ;)
eva2000
11 Jan 2004, 01:31
Okay, try the new files I attached :)
well new version reports less members than old version but still more than there really is heh
real members = 27
old script = 65
new version = 47
Gary King
11 Jan 2004, 01:39
It shows this for me:
Hack: Currently online: Members online: 6. Guests online: 12.
Forums: Currently Active Users: 16 (5 members and 12 guests)
Gary King
11 Jan 2004, 01:41
Anyways, I'm not too sure on why it doesn't work exactly correct on your forums, works fine on mine :)
great job!
big thx -> *install*
eva2000
11 Jan 2004, 04:39
Anyways, I'm not too sure on why it doesn't work exactly correct on your forums, works fine on mine :)
hmmm
http://animeboards.com/joinwink.php shows 202 members while forums really only have 39 members ???
tbh, i think that this should have been a BETA release, rather than a full one .
Also, i would like to see Members online and guests online :p
Gary King
11 Jan 2004, 16:43
tbh, i think that this should have been a BETA release, rather than a full one .
Also, i would like to see Members online and guests online :p
Yeah it has the s when there is more than 1, or should anyways :) It's like that on my test forum :)
Hi
I had a similar problem when i made some external site stats for my board. I think it's counting the total number of sessions in the table for members rather than for each unique id
replace:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
with:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
And it should solve the incorrect count of members.
Gary King
11 Jan 2004, 19:31
Hi
I had a similar problem when i made some external site stats for my board. I think it's counting the total number of sessions in the table for members rather than for each unique id
replace:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
with:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
And it should solve the incorrect count of members.
Okay could someone please confirm and if it is the correct query then let me know, I'll change in the instructions :)
eva2000
12 Jan 2004, 06:54
Okay could someone please confirm and if it is the correct query then let me know, I'll change in the instructions :)
spot on.. .
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
fixed it
Gary King
13 Jan 2004, 01:04
spot on.. .
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
fixed it
Okay I'll change in instructions then :)
Okay I'll change in instructions then :)
Okay.. I'm kind of confused.
What directory should online.php be located? I want all the names of the users online to be listed, so, I think I eed to use online.php. I tried putting it in the same directory as my files I want it to be displayed on, but it couldn't find the files it needed such as global.php. So, I tried to put it in the /forum directory, but it overwrote the online.php that vB needs, so I didn't want to do that.
What do I do?
Gary King
04 Mar 2004, 20:41
If you place the online.php outside of vB directory then just change the path to something else in the require_once() code.
Errors:
Warning: chdir(): No such file or directory (errno 2) in /home/dp/public_html/beta/online.php on line 9
Warning: main(./includes/init.php): failed to open stream: No such file or directory in /home/dp/public_html/forum/global.php on line 18
Fatal error: main(): Failed opening required './includes/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dp/public_html/forum/global.php on line 18
Online.php:
<?php
error_reporting(E_ALL & ~E_NOTICE);
$path = "./forum/"; // path to your forums folder, normally /forum/
$phrasegroups = array('wol');
chdir($path);
require_once("/home/dp/public_html/forum/global.php");
$showusernames = 1; // 1 to show usernames online, 0 to only show the number of users online
$datecut = time()-$vboptions['cookietimeout'];
if ($showusernames == 1)
{
$regmembers = $DB_site->query("SELECT DISTINCT username,options FROM ".$tableprefix."user,".$tableprefix."session
WHERE ".$tableprefix."session.userid=".$tableprefix."user.userid AND ".$tableprefix."session.lastactivity>$datecut
ORDER BY username ASC") or exit("oops2");
while($regmember = $DB_site->fetch_array($regmembers))
{
$regmember['options'] = intval($regmember['options']);
foreach($_USEROPTIONS as $optionname => $optionval)
{
$regmember["$optionname"] = iif($regmember['options'] & $optionval, 1, 0);
}
if ((($regmember['invisible'] == 0)) and $regmemberson or ($bbuserinfo['usergroupid'] == 6 and $regmember['invisible'] == 1))
{
$regmemberson .= ", ";
}
$regmembercomma++;
if ($regmember['invisible'] == 0 or $bbuserinfo['usergroupid'] == 6) {
if ($regmember['invisible'] == 1) {
$userinvisible = "*";
}
$regmemberson .= $regmember['username'].$userinvisible;
} else {
$regmembercomma++;
}
}
if (!$regmemberson)
{
$regmemberson = "(none)";
}
} else {
$regmembers = $DB_site->query_first("SELECT COUNT(DISTINCT userid) AS membersonline FROM ".$tableprefix."session WHERE userid>0 AND ".$tableprefix."session.lastactivity>$datecut") or exit("oops3");
$regmemberson = number_format($regmembers['membersonline']);
}
$howmany = substr_count($regmemberson,",");
if (($showusernames == 1 and $howmany >= 1) or ($showusernames == 0 and $regmemberson > 1))
{
$memberstext = $vbphrase['members'];
}
else
{
$memberstext = $vbphrase['member'];
}
$guests = $DB_site->query_first("SELECT COUNT(userid) AS guestsonline FROM ".$tableprefix."session WHERE userid=0 AND ".$tableprefix."session.lastactivity>$datecut") or exit("oops4");
if ($guests['guestsonline'] > 1)
{
$gueststext = $vbphrase['guests'];
}
else
{
$gueststext = $vbphrase['guest'];
}
$guestson = number_format($guests['guestsonline']);
$show = $memberstext.' '.strtolower($vbphrase['online']).': '.$regmemberson.'. '.$gueststext.' '.strtolower($vbphrase['online']).': '.$guestson.'.';
?>
Top of PHP page I want to include members on:
<?php require_once("online.php"); ?>
Table I want members to show up in, same page as last quote:
<table class="online">
<tr>
<td class="online" valign="top">
<span class="head">Who's Online</span><br /><br />
<?php
print $show;
?>
</td>
</tr>
</table>
Online.php and the file I want the members to show up on are in the same directory which is public_html/beta/ and the forum is public_html/forum/.
What am I doing wrong?
Gary King
05 Mar 2004, 21:34
Errors:
Online.php:
Top of PHP page I want to include members on:
Table I want members to show up in, same page as last quote:
Online.php and the file I want the members to show up on are in the same directory which is public_html/beta/ and the forum is public_html/forum/.
What am I doing wrong?
Change $path = "./forum/"; to $path = "./../forum/";
webrats
05 Mar 2004, 23:08
if i still this on a non vb page will it show the users browseing that page as guest?
Gary King
06 Mar 2004, 00:38
if i still this on a non vb page will it show the users browseing that page as guest?
Yep it should I believe.
webrats
06 Mar 2004, 00:41
i don see them showing up in my whos online
I have another way of tracking active users and it shows 250 in the last 5 min and this one that track it in 30 min is showing 120
Gary King
07 Mar 2004, 18:37
i don see them showing up in my whos online
I have another way of tracking active users and it shows 250 in the last 5 min and this one that track it in 30 min is showing 120
What's the other way that you use?
webrats
07 Mar 2004, 21:13
What's the other way that you use?
http://ripper.webrats.com
at the bottom i have the code
its not adding to the guest when someone visits that page
SlackerAPM
11 Mar 2004, 23:33
This is exactly the kind of thing I'm looking for however, I've had a few problems:
When using "online.php" everything is fine and working (formatting of the output text isn't great but that's easy enough to change). However, that's only the case while I'm logged into the boards, if I'm not logged in I get the "Unable to add cookies, header already sent." message. online.php works fine on it's own regardless of log in status, only the including seems to screw it up.
Using "online_external.php" outputs results regardless of login status however the results displayed on my page are similar to "Members online: 00, 0, 0, 0, 0, 0, 0, 0, 0. Guests online: 26." This is the case on the standalone page too.
I'm still don't fully understand the use of the
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
instructions, I'm probably a fool but they don't seem to be explained that clearly i.e. exactly which page we're adding this code to and whereabouts on the page it should be added to.
One other small request, any chance that when usernames are displayed by choice the names are links to the corresponding users profile (new window)?
Thank you for listening to my moaning ;)
hi! Is there a way to change the font style and size of this? Thanks in advance
1. Can the user names include the links to their profiles? if so, how do I add them?
2. Can the extra "most users online ... " text be added? if so, how?
3. Finally can the extra bit "Who visited today" also be added? That'd kick ass!
Thanks!
hi! Is there a way to change the font style and size of this? Thanks in advance
Simple HTML will do the trick you can use the <span></span> tags around the $show variable perhaps? I haven't tried it myself but it may work such as:
<span class=\"format\">$show</span>
or something like that. Of course you would have to define .class in your stylesheet. :D
Simple HTML will do the trick you can use the <span></span> tags around the $show variable perhaps? I haven't tried it myself but it may work such as:
<span class=\"format\">$show</span>
or something like that. Of course you would have to define .class in your stylesheet. :D
thanks but grateful if you could give me a more detailed instruction since im not that good in html. Thanks
instead of print $show maybe you can use
echo "<span style=\"font-family: Verdana; font-size: 12px\">$show</span>";
Obviously you can change the font-family and font-size to whatever else you want :)
Great! it works! Thanks a lot pal! :)
lifesourcerec
30 Apr 2004, 23:22
It works, but everything is crammed in. How can I fix this?
works great but i already have a require for my image upload script.
require_once("show_image.php");
require_once("online.php");
doesn't work together. is there any work around to this?
Gary King
10 May 2004, 13:19
works great but i already have a require for my image upload script.
require_once("show_image.php");
require_once("online.php");
doesn't work together. is there any work around to this?
Just remove the 'print' line from the online.php file and then put that wherever you want this list of online users to show up :)
JAB Creations
26 May 2004, 08:40
I want the code to tell me how many people are on my entire site, not just VB.
What code would I put in my PHP files to tell VB that people are not signed on (or are) and that they are looking at those pages?
That way my entire site will have this script tell me how many people are on my site in absolute total!
Gary King
26 May 2004, 13:09
Use
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
in every file (for the vB global.php file)
JAB Creations
26 May 2004, 15:00
Well now I've figured out what is wrong...
There are two things I want to do at once and I can at the moment only do either or.
This one will show me where users are when I goto the whose online? page.
<?php chdir("/home/jabcreat/public_html/community");
require_once('global.php'); ?>
This will display how many users are online, but NOT others on no-VB pages.
<?php chdir("/home/jabcreat/public_html/community");
require_once("online_external.php");?>
The problem is, you're either on VB and CANT see how many are on....
OR
You're NOT on VB but you CAN see how many people are on....
When I attempt to use both I recieve the following error...
Fatal error: Cannot redeclare iif() (previously declared in /home/jabcreat/public_html/community/includes/functions.php:318) in /home/jabcreat/public_html/community/online_external.php on line 10
So how do I get over my current comprimise?
i want it show on sidebar how can i do that?
i add
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
but it doesn't work
Baptizer
08 Jul 2004, 04:36
I am hoping Gary King is still around *crosses fingers*
Gary, any idea why I am getting the following results?
Members online: 00, 0, 0, 0, 0, 0, 0, 0, 0. Guests online: 26.
I tried to play with a few of the options, but I cant figure it out :(
Baptizer
09 Jul 2004, 02:38
Anyone else have a wild guess as to why this is occurring?
SKINVB
You have to
require the script first
then print show
I hope you understand that.
Baptizer....
I got the same thing...my solution...don't use online_external.php.
Instead use online.php
It took me a little bit but it worked...
ceck it out in my footer.
http://www.s3squad.com
misterfade
11 Aug 2004, 00:08
This hack is very good, but does anyone know how to show just the total number of registered members? I would really like this.
Thanks.
Toneboy
11 Aug 2004, 21:17
misterfade, if you know how to connect to your MySql database this query gets the registered number of users on your site:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Very basic, seen in action here (www.savedbygrace.org.uk/index.php).
SKINVB
You have to
require the script first
then print show
I hope you understand that.
Baptizer....
I got the same thing...my solution...don't use online_external.php.
Instead use online.php
It took me a little bit but it worked...
ceck it out in my footer.
http://www.s3squad.com
Yup, I concur :D
It worked on my site as well...I added the require_once bit at the very top of my HTML page (even before the <html> tag) then, wherever I wanted to display the online info I just added the print command. Basically the code on your page 'should' look like:
<?php require_once('/path/to/script'); ?>
<html>
<head>
</head>
<body>
....
(somewhere on your page you may now add:) <?php print $show ?>
Of course you have to name your page something like index.php (the extension is what matters here)
Hope that made it clear to everyone. Oh and yes, I am using online.php :)
BTW is there any way of adding links to user profiles?
JAB Creations
24 Sep 2004, 10:00
Members names are linked on my vb and its slightly hacked. Are you asking ahead of time or do you not see your members linked?
Members names are linked on my vb and its slightly hacked. Are you asking ahead of time or do you not see your members linked?
What vB? and no I don't see them linked.
Wordplay
18 Oct 2004, 21:28
is there a way to add the direct link to where the user is? because it just says on all the pages i added, that the member is viewing the startpage. no matter where they are.
I had to make a number of modifications to get this hack to work on my site (it's not very friendly with other scripts, changing dir, without changing back, not closing the mysql connection, etc... not good coding practices for something that's meant to work with meant other code).
However, after fixing it up, it works fine, and I've installed it :)
I've installed the script and it works perfectly. Great job.
nicedreams
07 Jan 2005, 01:08
I'm able to get the online_external version working somewhat, but when it try to show usernames online, it always says (none). When i switch it to not show the user name, it shows the correct number of members online. What's wrong?
Jim
ryancooper
27 Jan 2005, 15:49
Love it. . Installed It. . . Have One Question,
I am using online.php. The members usernames and guests all show up. . . is it a possability to link each members usernames to there profile?
ThankS!1
Anyway of having it show total users online rather than say members and guests.. so it appears
Users online: 302
CrimsonGT
23 Apr 2005, 00:40
It worked fine, but it threw off my alignment on the whole page. I have it all centered and when I included the file it made everything left aligned.
Also, is there anyway I can change the way it formats it? I want it to say like...
-Members Online: 23
-Visitors Online: 2
Basically is it possible just to pull the numbers out? Also, would it be possible to find the total number of members?
JohnBee
23 May 2005, 15:16
This works as advertised.
I am hoping to replicate my forum who's online style.
What would it take to get it looking like this:
Active users online: 2 (2 members and 0 guests)
JohnBee, testuser
Most users ever online was 20, 05-02-2005 at 02:50 PM.
Any help would be greatly appreciated.
JohnBee
23 May 2005, 18:56
Okay I modded the script somewhat to create the above mentioned look but
I'm stuck on the Most users online bit.
heres my code thus far:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
I removed all the extra's to help clear up things while manipulating the code.
I was thinking of pulling the data from the original /forum/online.php file
but I am uncertain of the approach to use, the code seems fairly long to
me and I'm pretty sure it can be reduced :)
any help would be greatly appreciated. thx
hypnoticpimp
16 Jun 2006, 16:31
i get MYSQL errors
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/wshh/public_html/online_external.php on line 14
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/wshh/public_html/online_external.php on line 15
I use vbulletin 3.5.4
Zidane007nl
20 Jun 2006, 23:55
The version doesn't work with vB 3.5.x I think then. You're posting in a topic from more than 1 year old and vB 3.5.x wasn't released back then.
hypnoticpimp
21 Jun 2006, 00:24
do u know any mods for 3.5.4 that can show whos online stats on a non vb page
napy8gen
11 Jul 2006, 15:02
Hi Gary King ..any plan to update this hack to 3.5.4 or next 3.6 ?
dstjohn
12 Aug 2006, 05:41
Not sure what happend to Gary since he hasnt posted on this hack
in quite some time, but fixing it to work with 3.5.4 was easy,
below are my changes to online_external.php
search for
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
and either comment that out or completely replace it with this.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Which will then produce the following output
Member online: X. Guest online: X.
Place the script outside your forums directory obviously ;)
dstjohn
12 Aug 2006, 05:52
Forgot to mention you need to run through the entire script
and do a search and replace.
search for all instances of $tableprefix
and replace with
$config['Database']['tableprefix']
dstjohn
12 Aug 2006, 05:57
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
vol_freak
21 Aug 2006, 16:02
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Anyone know how to get this to work with 3.6? It will display the number of members and guests online but I cannot get it to list the member names.
Any help would be greatly appreciated.
shortbus1662
25 Aug 2006, 05:09
is there any way to get this to work on a non .php page, like asp for instance?
If anyone can do this I'd love to speak with you.
danward
20 Feb 2007, 16:18
Great update dstjohn!! Would be great to get the usernames to work on 3.6 aswell!!
davidallsop
25 Apr 2007, 13:04
Is there anyway of getting the members online to display in the latest version of vBulletin? as Im looking for something a bit more than just the members online count.
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/c/..................../forum/online_external.php on line 19
:confused:
This wont work in 3.7.
??
Not a chance, this was written for vb 3.0.
Can anyone help me work out how i can display this on a non vbulletin page, with vbulletin 3.7 ??
vBulletin® v3.6.12, Copyright ©2000-2012, Jelsoft Enterprises Ltd.