Extension talk:WhosOnline

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] AdminSettings.sample

You are talking about a file AdminSettings.sample. Where is it? --ThorstenStaerk 10:49, 4 January 2012 (UTC)

[edit] Swap installation step 2 and 3

Running update.php to create db-tables only makes sense if WhosOnline already IS included in LocalSettings.php. Step 2 and step 3 could be swapped in the article to achieve this.

[edit] Users/Installers: Don't forget the prefix

In case your wiki uses a prefix (e.g. "mw") for the database tables, change the first line of the SQL instruction into something like:

CREATE TABLE `mw_online` (
    .....

Other than that:

  • This extension works fine with Mediwiki version 1.12.0
  • If you want to make a quicklink from the sidebar, edit MediaWiki:Sidebar and add something like:
 ** Special:WhosOnline|Who is online

- Daniel / edutechwiki.unige.ch

[edit] List visitors?

I would use this extensions since it's stable and hasn't got the UNIQ problem but as a special page it's not very useful. I think most users want to integrate the stats on Main Page or another exisiting page. E.g. Guests: 75, Users (2): Bob, Paul. WHat brings me to the next point. Ignoring the anonymous visitors is what makes me ignore this extension ;)

  • Btw: Works fine in 1.12 for me as well --Subfader 13:12, 12 May 2008 (UTC)


  • Thanks for this nice extension!

Works also fine in my 1.12 without any fiddling, but Subfader is right: connectable to a "$footerlinks" in "MyModifiedSkin.php" it would be even better. Difficult to implement? --michael 10:00, 16 May 2008 (UTC)

  • I also agree with Subfader. My wish list is integrable throughout the wiki and accounting for guests.

[edit] Having problem with sql table

I can't seem to add the sql table.

After entering this: CREATE TABLE mw_online (`userid` int(5) NOT NULL default '0',`username` varchar(255) NOT NULL default ,`timestamp` char(14) NOT NULL default , PRIMARY KEY USING HASH (`userid`, `username`),INDEX USING BTREE (`timestamp`)) TYPE=MEMORY;

I get this response -bash: syntax error near unexpected token `('

I think it's to do with the INDEX USING BTREE (`timestamp`) section.

Any ideas how to fix this?

Thanks

--LizK 09:23, 20 August 2008 (UTC)

No idea, sorry.
Assuming you have the extension files in $IP/extensions/WhosOnline, why don't you cd extensions/WhosOnline, edit whosonline.sql with your favorite text editor (nano, vim etc.), replace $wgDBprefix with mw_ and then run mysql -u [your mysql username here] -p [database name here] < whosonline.sql? That's a lot easier (for me, anyway) than copying and pasting stuff. :) --Sayuri 13:54, 20 August 2008 (UTC)

For $wgDBprefix, do I remove the /* */ that surrounds them too? Thanks. Fader 23:51, 26 March 2009 (UTC)


Ok, so this is a really old thread, but I wanted to comment that I got the .sql file to load by changing TYPE=MEMORY to ENGINE=MEMORY .
--Jlemley 18:07, 22 June 2011 (UTC)

[edit] Allow inclusion of the page

This patch allows inclusion of the Special page, in a similar way to Special:Newpages (eg. {{:Special:WhosOnline}}). If you use {{:Special:WhosOnline/10/shownav}} it will only show 10 users and will have the navigation controls.

Edit WhosOnlineSpecialPage.php and change line 79:

class SpecialWhosOnline extends SpecialPage {

to

class SpecialWhosOnline extends IncludableSpecialPage {

Then go to line 111 and change the rest of the execute() function from

 $pager = new PagerWhosOnline();
 
        $body = $pager->getBody();
 
        $wgOut->addHTML($pager->getNavigationBar());
        $wgOut->addHTML('<ul>'.$body.'</ul>');

to

 $pager = new PagerWhosOnline();
 
        $shownavigation = ! $this->including();
        if ( $para ) {
                $bits = preg_split( '/\s*,\s*/', trim( $para ) );
                foreach ( $bits as $bit ) {
                        if ( 'shownav' == $bit )
                                $shownavigation = true;
                        if ( is_numeric( $bit ) )
                                $pager->mLimit = $bit;
 
                        $m = array();
                        if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) )
                                $pager->mLimit = intval($m[1]);
                }
        }
 
        $body = $pager->getBody();
 
        if ($shownavigation) 
                $wgOut->addHTML($pager->getNavigationBar());
        $wgOut->addHTML('<ul>'.$body.'</ul>');
Wow, that works fine, Dude! Thanks a lot :-) -- Tommy us Kölle 13:59, 11 December 2009 (UTC)
I've applied this patch in r88591. --Jack Phoenix (Contact) 18:10, 22 May 2011 (UTC)

[edit] I liked this one

I liked the idea behind this extension, so I modified it a little to do more of what I wanted:

Can show partial IP addresses or 'Guest', page last viewed, and keeps active users at the top of the list, with updated page info.

WhosOnline list becomes more like this:

  1. Ace - Special:WhosOnline
  2. Guest - Wiki_Top_Ten

Example of 'Guest' view mode: http://www.gshi.org/wiki/Special:WhosOnline

See WhosOnline files for info and all-done file setup with version-agreeing files: http://www.gshi.org/ugetab/Wiki/

[edit] Hack to make it work with postgres

I had to change the create table script so that the php code would work with a postgres database:

CREATE TABLE online
(
  userid BIGINT NOT NULL DEFAULT 0,
  username CHARACTER VARYING(255) NOT NULL DEFAULT ''::CHARACTER VARYING,
  "timestamp" BIGINT NOT NULL,
  CONSTRAINT online_pk PRIMARY KEY (userid, username)
)
WITH (OIDS=FALSE);
ALTER TABLE online OWNER TO mediawiki;
 
-- Index: timestamp_idx
 
-- DROP INDEX timestamp_idx;
 
CREATE INDEX timestamp_idx
  ON online
  USING btree
  ("timestamp");

The biggest change was the type of timestamp from character to bigint.

I also had to change the php file WhosOnlineSpecialPage.php on line 107 so that it would look like this:

 $db->delete('online', array('timestamp < '.$old.''), __METHOD__);

Notice all I did was remove the double-quotes. Postgres thought it should be looking for a table.

[edit] Strange Issue

I have just upgraded my mediawiki from 1.9.2 to latest 1.15.1, and also installed the whosonline page, I get a strange error that each time I view the page, it is adding my user ? i.e. I have mulitple listings of my user in the page, how can I stop these duplicates ?

Many thanks

Mark

--Mark 09:20, 20 January 2010 (UTC)This is still happening, does anyone know how I can stop duplicates appearing ? Many thanks

[edit] Redlinks for users

Could you implement a feature which would display the links to the userpages as redlinks if they don't exist, like everywhere else in the wiki?--188.100.208.194 19:03, 21 June 2010 (UTC)

[edit] Special:WhosOnline shows no items

The Special:WhosOnline page shows no items when I visit it. I've to refresh it to show even myself. This is with v1.15.3 of mw and v1.15.x of the extension. --164.54.212.14 17:05, 28 June 2010 (UTC)

[edit] Special:WhosOnline shows only max. 50 users

The Special:WhosOnline page shows only max. 50 users. The Navigation (next 50|previous 50) doesn't work. Choose limit of 100 doesnt work, too. It stays at 50. My MediaWiki: 1.16.1. 77.1.95.212 18:14, 4 September 2011 (UTC)

A couple of issues are causing this. The below code snippets are from WhosOnlineSpecialPage.php.
First, in the function __construct, the limit is always being set to default, if even if you select something else. To fix, change this:
 function __construct() {
                parent::__construct();
 
                $this->mLimit = $this->mDefaultLimit;
        }


To this:


function __construct() {
        parent::__construct();
        if (!isset($this->mLimit)) {
                $this->mLimit = $this->mDefaultLimit;
        }
}


Next, find the function countUsersOnline(). Change this:


 
wfProfileIn(__METHOD__);
 
$row    = $this->mDb->selectRow('online', 'count(*) as cnt', 'userid != 0', __METHOD__);
$users = (int) $row->cnt;
 
wfProfileOut(__METHOD__);


To this:


global $wgWhosOnlineShowAnons;
wfProfileIn(__METHOD__);
 
$row    = $this->mDb->selectRow('online', 'count(*) as cnt', 
        $wgWhosOnlineShowAnons ? array() : array('userid != 0'), __METHOD__);
$users = (int) $row->cnt;
 
wfProfileOut(__METHOD__);


I hope this works for you!
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox