WhosWhere
Questions answered by this recipe
- How can I keep track of and show who is currently online and what they are doing on my wiki?
Description
Keep track of and display Who's Where and what they're doing on your site.
Notes
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.Foo | browse | 24:24 ago |
(not logged in) | Test.Sam | browse | 1:11 ago |
sally (Sally Smith) | Test.MyPage | edit | 0:31 ago |
john | Cookbook.WhosWhere | browse | 0: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 address | author |
12.23.34.45 | jack (Jack Bauer) |
132.121.23.1 | (not logged in) |
1.2.3.4 | sally (Sally Smith) |
4.3.2.1 | john |
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:
noauthheaderfmt | Header for non-authorized users |
noauthdetailfmt | Detail for non-authorized users |
headerfmt | Header for authorized users |
detailfmt | Detail for authorized users |
Installation
Place whoswhere.phpΔ in your cookbook directory and include the usual
include_once("
$FarmD
/cookbook/whoswhere.php");
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
- 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
Contributors
Roadmap, Requested Features
Comments
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.