Extension talk:WhosOnline/Archive 1

AdminSettings.sample

edit

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

Swap installation step 2 and 3

edit

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.

Users/Installers: Don't forget the prefix

edit

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

List visitors?

edit

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 ;)


  • 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)Reply

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

Having problem with sql table

edit

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)Reply

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)Reply

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


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)Reply

Allow inclusion of the page

edit

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)Reply
I've applied this patch in r88591. --Jack Phoenix (Contact) 18:10, 22 May 2011 (UTC)Reply

I liked this one

edit

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/

Hack to make it work with postgres

edit

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.

Strange Issue

edit

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 thanksReply

edit

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)Reply

Special:WhosOnline shows no items

edit

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)Reply

Special:WhosOnline shows only max. 50 users

edit

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)Reply

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!

Exclude bots/spiders ???

edit

Is there anyway to exclude bots/spiders form visitors list? (I have enabled $wgWhosOnlineShowAnons to show anonymous users) -- Thucproa1 (talk) 12:17, 16 February 2012 (UTC)Reply

Modify

edit
  • {{:Special:WhosOnline}}, {{:Special:WhosOnline/10/shownav}}.
  • 대문 페이지에 에디트하면, 아이피 목록이 나타나므로, '현재접속자:' . $total_guests . '명'으로 표시, 링크를 통해서 목록을 보여주게 수정.
class SpecialWhosOnline extends IncludableSpecialPage {
	public function __construct() {
		parent::__construct( 'WhosOnline' );
	}

	// get list of logged-in users being online
	protected function getAnonsOnline() {
		wfProfileIn( __METHOD__ );

		$dbr = wfGetDB( DB_SLAVE );

		$row = $dbr->selectRow(
			'online',
			'COUNT(*) AS cnt',
			'userid = 0',
			__METHOD__
		);
		$guests = (int) $row->cnt;

		wfProfileOut( __METHOD__ );

		return $guests;
	}

	public function execute( $para ) {
		global $wgOut, $wgDBname, $wgRequest, $wgTitle;

		$db = wfGetDB( DB_MASTER );
		$db->selectDB( $wgDBname );
		$old = gmdate( 'YmdHis', time() - 3600 );
		$db->delete( 'online', array( 'timestamp < "' . $old . '"' ), __METHOD__ );

		$this->setHeaders();

		#####  some guests ########################### 
		if ($wgRequest->getText( 'guests' ) == 'veiw' ) {
			return $this->GuestsVeiw();
		}

		$LocalPageUrl = '';
		$LocalPageUrl = $wgTitle->getFullURL();
		$total_guests = $this->getAnonsOnline();
		$wgOut->addHTML( '* <a href="'.$LocalPageUrl.'?guests=veiw' . '">' . '현재접속자:' . $total_guests . '명' . '</a>' );

	}

	###### GuestsVeiw function ###############################
	function GuestsVeiw() {
		global $wgOut;

		$pager = new PagerWhosOnline();


		$showNavigation = !$this->including();
		if ( $para ) {
			$bits = preg_split( '/\s*,\s*/', trim( $para ) );
			foreach ( $bits as $bit ) {
				if ( $bit == 'shownav' ) {
					$showNavigation = true;
				}
				if ( is_numeric( $bit ) ) {
					$pager->mLimit = $bit;
				}

				$m = array();
				if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
					$pager->mLimit = intval( $m[1] );
				}
			}
		}

		if ( $showNavigation ) {
			$wgOut->addHTML( $pager->getNavigationBar() );
		}

		$body = $pager->getBody();
		$wgOut->addHTML('<ol style="list-style-type:decimal;color:#555">' . $body . '</ol>');
		return;

    }

}
  • $para variable is what?
 $wgOut->addHTML( $para );
  • Values ​​are not displayed.
Return to "WhosOnline/Archive 1" page.