Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

How to - Display list of users online via SSI

Quote Reply
How to - Display list of users online via SSI
Instructions on how to display a list of members / guests currently viewing the forum
on any webpage via SSI (tested on .shtml pages)

Example (with visitors): Viewing the Forum: Pete, John, Dave and 15 guests

Example (without visitors): Viewing the Forum: No members and no guests

------------------------------

1. Create 2 globals:

(Admin/Templates/Global Vars)

Code:
TAG: online_now

GLOBAL:

sub {
my @found = ();
$DB->table('Online')->delete(GT::SQL::Condition->new(online_time => '<' => (time - $CFG->{online_timeout} * 60)));
my $table = $DB->table('Online','User');
my $sth = $table->select( { 'Online.online_invisible' => 0, 'User.user_invisible' => 0, 'Online.guest_id_fk' => 0 }, ['User.user_username'] );
while (my $userid = $sth->fetchrow_hashref){
push @found, $userid->{user_username};
}
return '' . (@found ? join(', ', @found) : 'No members');
}
Code:
TAG: online_guest

GLOBAL:

sub {
return $DB->table('Guest')->count( GT::SQL::Condition->new('guest_last_time', '>', time - 900) );
}

2. Create a template:

(Admin/Templates/User Templates)

To do this I opened .tplinfo and replaced the contents with the following then below where
it displays "Save template as:" rename it to ssi_online.html and click Save.


Code:
<html>
<head>
<%include include_css.html%>
</head>
<body bgcolor="<%light_green%>">
Viewing the Forums:</a> <%online_now%> and <%online_guest%> guests</font>
</body>
</html>
(This is just a basic code. You can change it to whatever font, color, etc. to match your site theme.)


3. Create an Action

(Admin/Setup/Actions)

Add Action - ssi_online
Description - ssi online (or whatever you want to call it)
Enabled - Yes
Page - ssi_online.html


To call it via SSI use the following (change to your path):

Code:
<!--#include virtual="/cgi-bin/forum/gforum.cgi?do=ssi_online"-->
Subject Author Views Date
Thread How to - Display list of users online via SSI MJB 4119 Apr 4, 2006, 4:23 PM
Thread Re: [MJB] How to - Display list of users online via SSI
MJB 4000 Apr 5, 2006, 12:58 AM
Post Re: [MJB] How to - Display list of users online via SSI
Andy 3999 Apr 5, 2006, 1:11 AM
Thread Re: [MJB] How to - Display list of users online via SSI
inboxcom 3946 May 11, 2006, 1:40 PM
Thread Re: [inboxcom] How to - Display list of users online via SSI
MJB 3916 May 11, 2006, 3:29 PM
Thread Re: [MJB] How to - Display list of users online via SSI
inboxcom 3923 May 12, 2006, 9:27 AM
Thread Re: [inboxcom] How to - Display list of users online via SSI
MJB 3890 May 12, 2006, 1:06 PM
Thread Re: [MJB] How to - Display list of users online via SSI
inboxcom 3886 May 12, 2006, 1:26 PM
Thread Re: [inboxcom] How to - Display list of users online via SSI
MJB 3890 May 12, 2006, 3:22 PM
Post Re: [MJB] How to - Display list of users online via SSI
MJB 3770 Jul 21, 2006, 2:49 PM