Summary: Show Who's Where on your wiki
Version: 2009-03-08
Prerequisites: SQL5, SQLite, PDO, PHP5
Status: Experimental
Maintainer: Peter Bowers
Users: (View? / Edit)
Download: whoswhere.phpΔ
Discussion: WhosWhere-Talk

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

  • How can I keep track of and show who is currently online and what they are doing on my wiki?


Keep track of and display Who's Where and what they're doing on your site.


Place the markup (:whoswhere:) in the location where you want the information to be displayed.

A table such as this will be displayed:

Who?Where?Doing What?When?
jack (Jack Bauer)Test.Foobrowse24:24 ago
(not logged in)Test.Sambrowse1:11 ago
sally (Sally Smith)Test.MyPageedit0:31 ago
johnCookbook.WhosWherebrowse0:00 ago

There are security implications to the use of this recipe. A hidden or secured group or page will be reported regardless of whether authorization is present. If that doesn't work for you site then you probably ought not to use this recipe. (Or else give me a suggestion how to limit it...)

The markup can be extended with arguments determining a header and the detail lines for either non-authorized users or authorized users. For example:

(:whoswhere noauthheaderfmt="|| border=1\n|| ip address || author ||" noauthdetailfmt="|| {ip} || {author} ||":)

If a non-authorized user viewed a page with that markup they would see something like this:

ip addressauthor (Jack Bauer) logged in) (Sally Smith)

However, an authorized viewer (someone who has logged in) would still see the default set of columns.

There are 4 variables that can be set within the markup:

noauthheaderfmtHeader for non-authorized users
noauthdetailfmtDetail for non-authorized users
headerfmtHeader for authorized users
detailfmtDetail for authorized users


Place whoswhere.phpΔ in your cookbook directory and include the usual


in your config.php.

If desired, override configuration variables. Defaults follow:

$wwSeconds         = 20*60;    // display activity within the last 20 minutes
$wwExpire          = 60*60*24; // keep info in the database for the last 24 hours
$wwDatabase        = "sqlite:$WorkDir/whoswhere.sqlite.db"; // database type/location
$wwHeaderFmt       = "|| border=1\n||! Who? ||! Where? ||! Doing What? ||! When?||";
$wwDetailFmt       = '|| {allauth} || {pn} || {action} || {date} ago||';
$wwNoAuthDetailFmt = '';
$wwNoAuthHeaderFmt = '';
$wwFields          = 'allauth|ip|authid|author|pn|action|date'; // {fields} that will be substituted
$wwNoAuthFields    = '';

In every case of a $wwNoAuth* variable it will default to the authorized variable value as long as the NoAuth value is blank. In other words as long as $wwNoAuthFields is blank (the default) it will use the $wwFields even if the user is not logged in.

Note in particular the potential for limiting which fields can be displayed for either authorized users ($wwFields) or non-authorized users ($wwNoAuthFields). If a field is requested which is no allowed (for instance, someone could ask for a sensitive field via the markup) then the field will appear, but it will simply not be substituted with an appropriate value.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • 2009-03-08 Allowed over-ridable defaults both with the markup and with the PHP configuration. Allowed limiting which fields would be substituted for an authorized user and for an unauthorized user separately. Added an IP field to the database. Note that you must delete your database file "wiki.d/whoswhere.sqlite.db" if you are upgrading from a previous version.
  • 2009-03-07b Switched from SQLite "raw" to SQLite through PDO for greater future flexibility. Improved error handling, changed the format of the output somewhat.
  • 2009-03-07 Initial release

See Also


Roadmap, Requested Features


See discussion at WhosWhere-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.