Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 12, 2012, 06:02:56 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Interested in joining the WebsiteBaker team?
For more Information read
here
or on our
new website
.
149621
Posts in
21098
Topics by
7537
Members
Latest Member:
lotte2
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
New Snippet: Users Online
Pages: [
1
]
2
Go Down
Author
Topic: New Snippet: Users Online (Read 7568 times)
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
New Snippet: Users Online
«
on:
August 22, 2008, 03:30:19 PM »
In the series fun snippets, here is the
Users Online
snippet.
It displays a simple line that says "Currently: 21 users online".
Hovering over the line a tooltip popup will display a timestamp and the page that is being viewed.
When called with your "admin" IP address it will also display the IP address of the visitors and if it is called by a searchbot. (experimental bot detection).
See the snippet in action on
http://www.wbhulp.nl
(Dutch website) in the right top of the page.
Installation:
Install the zipfile as a normal module through the WB backend.
Add the php code to your template index.php.
Using the snippet:
Code:
<?php UsersOnline
();
?>
Optional parameters:
<?php UsersOnline
(
$use_tooltip
,
$prefix
,
$suffix
,
$single
,
$admin_ip
)
?>
$use_tooltip = Adds a small javascript to display a hovering tooltip with details of the current connections. (default := 1, 0 no tooltip)
$prefix = The text in front of the user counter. ( default := "Currently: " )
$suffix = The text after the user counter when there is more than one user online. (default = " users online")
$single = The text after the user counter when there is just one user online. (default = " user online")
$admin_ip = The IP address that will see more details. Details are IP address and browser name (if detected) (default := "127.0.0.1")
Customised Example:
<?php UsersOnline
(
1
,
"Online: "
,
" users"
,
" user"
,
"192.168.0.1"
) ;
?>
Have fun with it.
Ruud
«
Last Edit: January 07, 2011, 11:27:51 PM by Ruud
»
Logged
Professional WebsiteBaker Developer
erpe
Offline
Posts: 2077
Re: New Snippet: Users Online
«
Reply #1 on:
August 22, 2008, 04:11:21 PM »
Hi Ruud,
want to invite you to work with us on this project:
http://www.websitebakers.com
We are just a half step behind (or in front of) the start line....
rgds
erpe
«
Last Edit: November 12, 2008, 03:16:51 PM by erpe
»
Logged
stories about
be part of the Tutorials-Project
visit the jQuery-Showroom
aldus
Offline
Posts: 1238
Re: New Snippet: Users Online
«
Reply #2 on:
August 23, 2008, 05:06:52 PM »
Hello Ruud
A nice one, and on a first look, clean as fresh fallen snow
But there are some unnessesary spaces instead of tabs,
seen in the attachment ... hard work for the preprocessor
Regards
Aldus
Logged
pfreud01
Offline
Posts: 34
Re: New Snippet: Users Online
«
Reply #3 on:
September 09, 2008, 03:09:36 PM »
is it possible to display the name of registered users online in this snippet? i don´t know to manage it.
best regards, pfreud01
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: New Snippet: Users Online
«
Reply #4 on:
September 09, 2008, 03:17:45 PM »
No,
The data recorded by the snippet does not include that.
So it is not possible to display.
Maybe in a future version.
Ruud
Logged
Professional WebsiteBaker Developer
bupaje
Offline
Posts: 519
Re: New Snippet: Users Online
«
Reply #5 on:
September 18, 2008, 03:20:15 AM »
Dumb question but is this registered users only, or total online users? Also if total users can it can be modified to show an image for every x amount of users with the numbers?
I was thinking it might be cool to create something like little characters, possibly with simple gif animations, hanging out in the stat box as a visual representation of how many users are online.
Logged
My Blog, My Site
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: New Snippet: Users Online
«
Reply #6 on:
September 18, 2008, 08:28:02 AM »
Quote from: bupaje on September 18, 2008, 03:20:15 AM
Dumb question but is this registered users only, or total online users?
It's total users. (and bots)
Quote from: bupaje on September 18, 2008, 03:20:15 AM
Also if total users can it can be modified to show an image for every x amount of users with the numbers?
I was thinking it might be cool to create something like little characters, possibly with simple gif animations, hanging out in the stat box as a visual representation of how many users are online.
It's open source. Be my guest.
Ruud
Logged
Professional WebsiteBaker Developer
bupaje
Offline
Posts: 519
Re: New Snippet: Users Online
«
Reply #7 on:
September 18, 2008, 03:01:14 PM »
Thanks Ruud.
Logged
My Blog, My Site
bupaje
Offline
Posts: 519
Re: New Snippet: Users Online
«
Reply #8 on:
November 14, 2008, 07:40:15 PM »
Has anyone had any problems with this? It has been working fine when suddenly today the page stops loading at this call
Code:
<?php UsersOnline
(
1
,
"Currently: "
,
" visitors viewing this page"
,
" visitor viewing this page"
) ;
?>
Logged
My Blog, My Site
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: New Snippet: Users Online
«
Reply #9 on:
November 14, 2008, 11:04:27 PM »
Quote from: bupaje on November 14, 2008, 07:40:15 PM
Has anyone had any problems with this? It has been working fine when suddenly today the page stops loading at this call
Code:
<?php UsersOnline
(
1
,
"Currently: "
,
" visitors viewing this page"
,
" visitor viewing this page"
) ;
?>
Is it still displaying anything?
Did you try to set the error reporting (advanced admin settings) to display all errors to see if it tells something?
I have it running on
my site
since day one without problems.
Ruud
Logged
Professional WebsiteBaker Developer
bupaje
Offline
Posts: 519
Re: New Snippet: Users Online
«
Reply #10 on:
November 14, 2008, 11:33:22 PM »
Must be something Yahoo webhosting changed. I got a message today that they disabled some features because I got a new credit card number and forgot to tell them, so they couldn't charge me. Maybe that did it though everything else seems to work.
I tried to run it out of WB in a php page no luck. I also tried another script I found online that counts sessions as an alternative
http://www.devarticles.com/c/a/PHP/The-Quickest-Way-To-Count-Users-Online-With-PHP/1/
and no luck.
Hmm... just curious I use opendns.org - is it possible that somehow blocks access to my 'more info' ip that your snippet is looking for. In other words maybe only I cannot see it? I just added the code back, can you see the little gray box with user info at the bottom?
http://www.stormvisions.com/pages/home.php
Logged
My Blog, My Site
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: New Snippet: Users Online
«
Reply #11 on:
November 14, 2008, 11:59:16 PM »
Yes, there is a grey block at the bottom of the page.
The more info just compares ip addresses as strings. That cannot be an issue.
The other script is totally different, not using IP adresses, not using database. It's very strange both of the scripts don't work.
Database communication still works (you would not have pages if it didn't)
Can you still create or update normal pages?
Did Yahoo tell what features were disabled?
Ruud
Logged
Professional WebsiteBaker Developer
bupaje
Offline
Posts: 519
Re: New Snippet: Users Online
«
Reply #12 on:
November 15, 2008, 12:08:28 AM »
No, they didn't say which ones. everything else seems normal. Very starnge.
I was able to implement this script found online
http://ronsguide.com/php/online/2/
and it outputs normally on my test page. It writes to a flatfile database if that sheds any light.
Logged
My Blog, My Site
vyni
Offline
Posts: 566
Re: New Snippet: Users Online
«
Reply #13 on:
November 15, 2008, 02:23:20 PM »
Hi,
right now I had a look, and everything looks good to me.
Logged
PS: Falls jemand eine Idee hat was zu tun ist und mir das erklären könnt - geh bitte davon aus dass ich ahnungslos bin, was php und so betrifft. Ich kann grad was lesen, kopieren und einfügen, ungefähr verfolgen und glauben.
bupaje
Offline
Posts: 519
Re: New Snippet: Users Online
«
Reply #14 on:
November 15, 2008, 04:39:11 PM »
That is a different script now - not very accurate either it seems.
Logged
My Blog, My Site
mracon
Offline
Posts: 1
Re: New Snippet: Users Online
«
Reply #15 on:
August 22, 2009, 11:18:58 AM »
Where can I download the zip file, the download link takes me here.
Logged
erpe
Offline
Posts: 2077
Re: New Snippet: Users Online
«
Reply #16 on:
August 22, 2009, 11:28:04 AM »
Users Online
rgds
erpe
Logged
stories about
be part of the Tutorials-Project
visit the jQuery-Showroom
Hans>NULL
Offline
Posts: 1389
Re: New Snippet: Users Online
«
Reply #17 on:
September 14, 2009, 07:53:53 PM »
Hi
Get an error when setting E_Strict
Code:
Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /www/modules/usersonline/include.php on line 38
Regards, Hans>NUL
«
Last Edit: September 14, 2009, 08:03:15 PM by Hans>NULL
»
Logged
/dev/null Ort ohne Wiederkehr
crnogorac081
AddOn Development
Offline
Posts: 1680
Re: New Snippet: Users Online
«
Reply #18 on:
September 14, 2009, 09:12:48 PM »
I got the same notification in PM module i built. I think it is just a note, not an error..
For example, If my hosting server is in US and I am in europe, I will set timezone to my local timezone in europe..
So its stupit to use same timezone from US , right ? I belive this is it...
If I am wrong someone please tell us what to do
)
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Hans>NULL
Offline
Posts: 1389
Re: New Snippet: Users Online
«
Reply #19 on:
September 14, 2009, 10:27:13 PM »
Ok, then a another message
xhtml-Error:
Code:
<p id="usersonline"><script language="JavaScript1.2" src="http://127.0.0.1:4001/wb28/modules/usersonline/overlib_mini.js" type="text/javascript"></script><span href="javascript:void(0);" onmouseover="return overlib('23:13:06 [127.0.0.1] /wb28/ (Home) - Firefox<br/>',HAUTO,VAUTO,WIDTH,600,BGCOLOR,'#FFFFFF',FGCOLOR,'#FFFFFF',BORDER,5,WRAP);" onmouseout="return nd();">1 Besucher Online: </span> </p>
The "href" attribute is not valid for the "span" element.
Regards, Hans>NUL
Edit: Currently I am testing a few Snippets & Modules
«
Last Edit: September 15, 2009, 01:43:24 PM by Hans>NULL
»
Logged
/dev/null Ort ohne Wiederkehr
Vasiliy
Offline
Posts: 18
Re: New Snippet: Users Online
«
Reply #20 on:
December 03, 2009, 10:39:15 PM »
Good evening!
I put this module on my website.
http://validator.w3.org/check
found a lot of mistakes.
I have corrected all the errors.
You should find the file include.php and replace this code:
Quote
if ($use_tooltip != 0) {
while($res = $counter_res->fetchRow()) {
if ($admin_ip == $ipaddress)
$userlist .= date("H:i:s",$res['timestamp'])." [".$res['ip']."] ".$res['page']." (".$res['page_title'].") ".bot($res['user_agent'])."<br/>";
else
$userlist .= date("H:i:s",$res['timestamp'])." - ".$res['page']." (".$res['page_title'].")<br/>";
}
echo '<SCRIPT language="JavaScript1.2" src="'.WB_URL.'/modules/usersonline/overlib_mini.js" type="text/javascript"></SCRIPT>';
echo "<span href=\"javascript:void(0);\" onmouseover=\"return overlib('$userlist',HAUTO,VAUTO,WIDTH,600,BGCOLOR,'#FFFFFF',FGCOLOR,'#FFFFFF',BORDER,5,WRAP);\" onmouseout=\"return nd();\">";
}
if($user == 1) {
echo $prefix.$user.$single;
} else {
echo $prefix.$user.$suffix;
}
if ($use_tooltip != 0)
echo "</span>";
and put the following code:
Quote
if ($use_tooltip != 0) {
while($res = $counter_res->fetchRow()) {
if ($admin_ip == $ipaddress)
$userlist .= date("H:i:s",$res['timestamp'])." [".$res['ip']."] ".$res['page']." (".$res['page_title'].") ".bot($res['user_agent'])."<br />";
else
$userlist .= date("H:i:s",$res['timestamp'])." - ".$res['page']." (".$res['page_title'].") <br />";
}
echo '<script language="JavaScript1.2" src="'.WB_URL.'/modules/usersonline/overlib_mini.js" type="text/javascript"></script>';
echo "<a href=\"javascript:void(0);\" onmouseover=\"return overlib('$userlist',HAUTO,VAUTO,WIDTH,600,BGCOLOR,'#FFFFFF',FGCOLOR,'#FFFFFF',BORDER,5,WRAP);\" onmouseout=\"return nd();\">";
}
if($user == 1) {
echo $prefix.$user.$single;
} else {
echo $prefix.$user.$suffix;
}
if ($use_tooltip != 0)
echo "</a>";
Logged
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4753
Re: New Snippet: Users Online
«
Reply #21 on:
December 07, 2009, 06:32:53 PM »
Hello Ruud,
I am going to use this nice snippet on a project.
It's very nice but I would like to show something like:
currently 35 users online | 15
logged in
and 20
visitors
.
Could this be implemented somehow?
Maybe you can give me some hints, so I can learn and do the rest myself (with some help).
Kind regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: New Snippet: Users Online
«
Reply #22 on:
December 07, 2009, 10:40:51 PM »
To do that it will need an extra field in the counter table.
A simple check on the session variable could be done to see if the current user is logged in.
A bit more logic will be needed to query the table to produce the correct counters.
Some extra parameters will be needed to be accepted to display more text fragments.
If I find some time the next few days, I will have a look to see if I can add this feature.
I think this is not te best project to start learning PHP coding.
R
Logged
Professional WebsiteBaker Developer
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4753
Re: New Snippet: Users Online
«
Reply #23 on:
December 08, 2009, 01:02:33 AM »
Hello Ruud,
thanks for your hints, and yes, reading your explanations I agree with ...
Quote from: Ruud on December 07, 2009, 10:40:51 PM
I think this is not te best project to start learning PHP coding.
And if you find some time it would be a very nice extension for this snippet.
Kind regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
WDStudio
Offline
Posts: 14
Re: New Snippet: Users Online
«
Reply #24 on:
March 02, 2010, 09:15:51 PM »
How can I set timezone (GMT +1) for this module?
Logged
Pages: [
1
]
2
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
-----------------------------
English
-----------------------------
=> Help & Support
-----------------------------
General
-----------------------------
=> WebsiteBaker Website Showcase
-----------------------------
English
-----------------------------
=> Modules
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
-----------------------------
General
-----------------------------
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
-----------------------------
General
-----------------------------
=> Security Announcements
-----------------------------
Deutsch (German)
-----------------------------
=> Hilfe/Support
-----------------------------
General
-----------------------------
=> Documentation
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
=> Module & Snippets
-----------------------------
English
-----------------------------
=> Archive (posts up to 2007)
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Deutsch (German)
-----------------------------
=> jQuery
=> Tutorials
=> Templates & Design
-----------------------------
English
-----------------------------
=> jQuery
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
===> Suggestions
-----------------------------
Deutsch (German)
-----------------------------
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
===> Vorschläge
-----------------------------
English
-----------------------------
===> Software bugs
-----------------------------
Deutsch (German)
-----------------------------
===> Softwarefehler
=====> Module / Extensions
-----------------------------
English
-----------------------------
=====> Modules / Extensions
-----------------------------
Deutsch (German)
-----------------------------
===> Erfahrungs und Testberichte
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...