==README for addon_whosonline.php==
Release date: February 23, 2005.
Most recent update: January 27, 2026.
miniBB version: 3.5 and up
Author: Paul Puzyrev (minibb.com)

Add-on displays THE INSTANT amount of the currently logged forum members, and optionally the amount of guests determined by session ID. User's activity is broken after defined period of time. Since updating user's online data is very frequent and simultaneous operation, add-on doesn't use database for storing it's data, but uses simple array file. That's why you need to be sure your PHP supports writing and creating of PHP files, which may be often disallowed in Safe Mode.

==INSTALLATION==

*) Create a subfolder in your forums root folder, named "shared_files", and give it full-access permissions for writing (0777). This folder may be used by other add-ons as well; if it's already created, just skip this step.

*) Edit your language pack (lang/eng.php or related) and at the end of it, paste definitions located under lang/eng.code.txt; if this needs a translation, put under the proper language pack.

*) Copy the file addon_whosonline.php to your forums root folder.

*) Copy the file shared_files/addon_whosonline_data.php to your "shared_files" folder and and give it full permissions for writing (0777).

*) Add the variable {$whosOnline} somewhere in templates/main_footer.html (or templates/main_header.html, on your choice)

*) Paste in your bb_plugins.php the code provided under bb_plugins.code.txt. Modify add-on's options if needed. Be VERY careful and MAKE SURE setting the $enableHidden option! It requires additional actions applied (read below). Without them it won't work!!

ATTENTION! The code for bb_plugins.php most likely should always appear AT THE TOP of that file, for example:

<?php
if (!defined('INCLUDED776')) die ('Fatal error.');

/* Who's Online */
include($pathToFiles.'addon_whosonline.php');
/* --Who's Online */

/* ........... other plugins code(s) below */

?>

Or, if you've installed Captcha add-on, this code should be pasted BELOW the Captcha code. For example:

<?php
if (!defined('INCLUDED776')) die ('Fatal error.');

/* Captcha code here.... */

/* .....End of the Captcha code */

/* Who's Online */
include($pathToFiles.'addon_whosonline.php');
/* --Who's Online */

/* ........... other plugins code(s) below */

?>



==ENABLING ONLINE STATUS IN THREADS==

*) Member's online status is indicated, displaying the icon from img/online_status.svg. Usually this icon is displayed beneath the username in threads. You are allowed to modify this icon upon your taste. When you are done, copy this icon to the /img/ folder of your server. 

*) Copy templates/addon_whosonline_status.html to the forum's /templates/ (contains HTML block for the Profile page, which you are free to adjust as well).

*) Modify bb_plugins.php and locate the function parseMessage(). If it's not there, just paste the full code from bb_plugins_parseMessage.code.txt, ELSE paste the only proper block of code before 'return' statement. Duplication of the function's definition leads to the critical PHP error, be careful with that!

*) Modify templates/main_posts_cell.html and paste {$uoIcon} indicating online status. Most preferrably it should be pasted after HTML for username, for example:

<span class="username">{$pLink1}{$posterName}{$pLink2}</span>{$uoIcon}



==BUNDLING WITH THE 'HIDDEN' OPTION FOR MEMBERS==

The add-on has possibility to be extended to allow users show or hide their status online in their profiles, and to show their status in messages near username. This possibility needs an additional field added to the users table and few other very specific modifications. In all aspects, adding extra field is completed following default miniBB algorithm regarding new profile fields which is described here: http://www.minibb.com/new_profile_field.html 

This solution is FOR EXPERIENCED CODERS only! It should be applied ONLY if you are already running the add-on successfully in the basic mode.

Steps to complete are the following:

*) Execute the following SQL adding the new field to the profile (substitute table name for your own):

alter table minibbtable_users add column user_customonline int(1) not null default '1';

*) Using "determine_fields.php" script, determine the order number of the new field.

*) Modify setup_options.php - $dbUserSheme, setting up the new field with the proper order number. For example, add:

'user_customonline'=>array(27, 'user_customonline', 'online'),

where '27' should stand for your above determined order number.

*) Paste to the templates/user_dataform.html the following:

{$onlineStatusForm}

- it will be substituted for an option of choosing the online status.

*) Edit bb_plugins_user.php and paste the code located under bb_plugins_user.code.txt (preferrably before the closing ?>).

*) The most difficult step: you will need to modify bb_cookie.php file and add everything associated to forming the $userOnline variable. This step could be strictly different for custom authorization modules, below we provide the solution only for default miniBB auth.

- To the SQL request for admin's auth, which looks like:

if($row=db_simpleSelect(0,$GLOBALS['Tu'],$GLOBALS['dbUserSheme']['user_sorttopics'][1].','.$GLOBALS['dbUserSheme']['language'][1].', '.$GLOBALS['dbUserSheme']['num_posts'][1],$GLOBALS['dbUserId'],'=',1))

add the new field to select:

if($row=db_simpleSelect(0,$GLOBALS['Tu'],$GLOBALS['dbUserSheme']['user_sorttopics'][1].','.$GLOBALS['dbUserSheme']['language'][1].', '.$GLOBALS['dbUserSheme']['num_posts'][1].', '.$GLOBALS['dbUserSheme']['user_customonline'][1], $GLOBALS['dbUserId'],'=',1))

- Locate the string saying: $username=$GLOBALS['admin_usr']; - and paste the following right after it:

$GLOBALS['user_online']=$row[3];

- To the SQL request for member's auth, which looks like:

elseif($row=db_simpleSelect(0,$GLOBALS['Tu'],$GLOBALS['dbUserId'].','. $GLOBALS['dbUserSheme']['user_sorttopics'][1].','. $GLOBALS['dbUserSheme']['language'][1].','. $GLOBALS['dbUserAct'] .','. $GLOBALS['dbUserSheme']['user_password'][1] .', '.$GLOBALS['dbUserSheme']['username'][1].', '.$GLOBALS['dbUserSheme']['num_posts'][1], $caseComp1.$GLOBALS['dbUserSheme']['username'][1].$caseComp2,'=',$usernameSql,'',1)){

add the new field to select:

elseif($row=db_simpleSelect(0,$GLOBALS['Tu'],$GLOBALS['dbUserId'].','. $GLOBALS['dbUserSheme']['user_sorttopics'][1].','. $GLOBALS['dbUserSheme']['language'][1].','. $GLOBALS['dbUserAct'] .','. $GLOBALS['dbUserSheme']['user_password'][1] .', '.$GLOBALS['dbUserSheme']['username'][1].', '.$GLOBALS['dbUserSheme']['num_posts'][1].', '.$GLOBALS['dbUserSheme']['user_customonline'][1], $caseComp1.$GLOBALS['dbUserSheme']['username'][1].$caseComp2,'=',$usernameSql,'',1)){

- Locate the string saying: $GLOBALS['user_num_posts']=$row[6]; - and paste the following right after it:

$GLOBALS['user_online']=$row[7];

*) Set the option $enableHidden=1; under bb_plugins.php. Under the same file, optionally you may set up/uncomment the condition which displays Who's Online block only for admin and those users allowed to show their status.

*) The condition under bb_plugins.php's parseMessage() function, in /* Show Online Status */ block, should be set up/uncommented as well to display "Offline" icon if user is online, but has chosen to hide his status.


==NOTES==

Identifying of guests is done storing an extra cookie. Counting guests begins from opening the next forums page; if cookie wasn't set, the user is considered as a robot or automated script and is not taken into account.


==FINALLY==

Hope, you'll enjoy. Please, post bugs and suggestions on our forums:
http://www.minibb.com/forums/11_4317_0.html
