"Who's Online"

Version 1.0 - Beta 2

January 07, 2003

Written by Rick Ellis

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

CHANGE LOG

V 1.0 - Beta 1
- Added "most users ever" feature

V 1.0 - Beta 2
- Streamlined the code in a couple areas.
- Added some error correction.
- Made a slight change in how the log file data is compiled.

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


INSTRUCTIONS:

There are two files included in this package:

online_users.php

online_users.txt

Place both files inside the "scripts" directory, located
inside your main script ("pm") directory.

Then chmod "online_users.txt" to 666.

Make sure you chmod "online_users.txt" to 666 and NOT "online_users.php".

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

USAGE:

Once you've installed the scripts, you can use the following
code on any pMachine page to display the number of members
and guests that are viewing your web page.

You can customize the "who's online" feature to look anyway you
want. 

There are six tags, and one loop which can be used
to display the members and guests who are online.

-- 

<?php $user_array = online_users(); ?>

This tag invokes the "who's online" feature.
This tag doesn't display anything on it's own, but is required:

The tag has one optional parameter that lets you set the amount of
time each user will remain in the list without refreshing the page.
If you leave the tag as shown, the default is 12 minutes.  

If, for example, you want it to remain active for 15 minutes, you would
use the tag like this:

<?php $user_array = online_users("15"); ?>

--

<?php echo $user_array['1']; ?>

Displays the number of logged-in members

--
 
<?php echo $user_array['2']; ?>

Displays the number of guests (non-members)

--

<?php echo $user_array['3']; ?>

Displays the combined total number of visitors

--

<?php echo $user_array['4']; ?>

Displays the most visitors that were ever at your site at one time

--

<?php echo date("M d, Y", $user_array['5']); ?>

Displays the date/time when the most-ever visitors were present.
You can use PHP timestamp codes in this tag.  Look in the
manual for a list of available tags.  To change the date/time,
replace "M d, Y" with any other codes.

--

And finally, this loop shows the name of each logged
in member, formatted as a link to their profile page:

<?php
for ($i=0; $i<sizeof($user_array['0']); $i++)
{
	echo $user_array['0'][$i];
	
	echo "&nbsp;"; // Delimiter between member names	
}
?> 
 
-----------------------------------------------------------------------

HERE IS THE COMPLETE EXAMPLE, WITH TEXT FORMATTING: 


Who is Online?
<br />

<?php $user_array = online_users(); ?>

Guests: <?php echo $user_array['2']; ?>

<br />

Members: <?php echo $user_array['1']; ?>

<br />

Total visitors: <?php echo $user_array['3']; ?>

<br />

The most guests ever was <?php echo $user_array['4']; ?>

on <?php echo date("M d, Y", $user_array['5']); ?>


<br />

<?php
for ($i=0; $i<sizeof($user_array['0']); $i++)
{
	echo $user_array['0'][$i];
	
	echo "&nbsp;"; // Delimiter between member names	
}
?>

