Extension talk:WhosOnline/Archive 2

Where the users are
Hello, thanks for the extension. Is it possible to show in wich page the user is? It would be very useful. Thank you. - 5.150.135.196 09:47, 20 November 2015 (UTC)
 * Just see web server log. - PlavorSeol | T | C 05:43, 29 September 2018 (UTC)

Wish: Permit staying invisible
Hi, thanks for this wonderful extension which works smoothly on our closed 1.23.8 Mediawiki. It's inspiring to see the fellow user's interest. But, sometimes, depending on atmospheric pressure ;-), one might want to log in without being seen. I wonder how to make this possible. Perhaps just through a special URL parameter or so? Avacpio (talk) 05:24, 12 December 2014 (UTC)


 * If one is only reading, one does not have to log in. If one has to log in for doing an edit, one will be seen in the RC anyway. So, what would be the use? --Manorainjan (talk) 22:51, 6 February 2017 (UTC)
 * Thx for responding. No, we're running a closed wiki, one has to log in for reading. --Avacpio (talk) 09:25, 14 February 2017 (UTC)


 * So,. the public is excluded in any way. You are amongst trusted members of the community only. And still You want to lurk around unseen? I do not think, that the solution to this problem is a technical one. -- Manorainjan  09:57, 14 February 2017 (UTC)


 * Once again: our MediaWiki is closed (no read-access for public). We're a community (a church) of ~120 users. We've "WhosOnline" on the main page. Fine. It's important, and I assured all members, that no one can track which pages are being read by anyone. But if you read, for hours, or days, everyone always see's that u'r logged in. Sometimes this is not desirable. So, I would like to give (or program - but I've not enough time, and am not used to php) an option to log in and read totally invisible. ("bypass whosonline for this session"). My question is, whether someone here perhaps already has a solution or is able/willing to create one.
 * In this context please also see this < 3 mins explanation by Eben Moglen: http://www.youtube.com/watch?v=86MZBAW_DLE
 * --Avacpio (talk) 05:43, 19 October 2017 (UTC)

Bug in MW 1.24 ?
Hi, there seems to be a little bug for the special page. The does work.

[Fri Dec 12 19:34:56 2014] [error] [client 129.194.30.22] PHP Catchable fatal error: Argument 1 passed to Language::viewPrevNext must be an instance of Title, string given, called in /export/data/portails/fmediawiki/extensions/WhosOnline/WhosOnlineSpecialPage.php on line 84 and defined in /export/data/portails/fmediawiki/languages/Language.php on line 4633, referer: http://edutechwiki.unige.ch/fr/Bases_psychop%C3%A9dagogiques_des_technologies_%C3%A9ducatives

Life example: http://edutechwiki.unige.ch/fr/Sp%C3%A9cial:Qui_est_en_ligne

- Daniel K. Schneider (talk) 18:46, 12 December 2014 (UTC)


 * The Problem is wfViewPrevNext used in getNavigationBar, Deprecated since 1.19 and removed in 1.24. You should replace getNavigationBar in WhosOnlineSpecialPage.php with this:

function getNavigationBar { global $wgContLang,$wgLang;

$query = ''; $offset = $this->mOffset; $limit = $this->mLimit; $link = $wgContLang->specialpage( 'WhosOnline' ); $atend = $this->countUsersOnline < ( $this->mLimit + $this->mOffset ); // show next link $query = wfCgiToArray( '' ); if( is_object( $link ) ) { $title = $link; } else { $title = Title::newFromText( $link ); if( is_null( $title ) ) { return false; }		}

return $wgLang->viewPrevNext(			$title,			$offset,			$limit,			$query,			$atend); } }

May be not perfect but it work. --79.209.109.156 18:48, 21 December 2014 (UTC)
 * Yes I can confirm too that the solution above works with MW1.24 (example). Thanx again ! Would be nice if someone who has the powers and the know how could merge it into the Git master :) - Daniel K. Schneider (talk) 10:09, 21 April 2015 (UTC)

Update: Tried to get this extension working in 1.23 and received the same error-message, but the above modification is a correct solution to get it working in MW 1.23.

New Bug in Mediawiki 1.24
Hi

Did the change listed above to get the Special Page working. But now I get the following error:

Notice: Undefined variable: link in mediawiki/htdocs/extensions/WhosOnline/WhosOnlineSpecialPage.php on line 88


 * It fixed my issues.  Mlpearc  ( open channel ) 20:34, 4 January 2015 (UTC)


 * change  to    --178.24.206.247 20:13, 15 January 2015 (UTC)

Show the online time a user is logged on
Hi, I like the extension, but I'm also interested in seeing how long a user is online, so I made a few modifications, giving me the following output:

Who's online View (previous 50 | next 50) (20 | 50 | 100 | 250 | 500)

161.90.43.138 Online for 0 hours 24 minutes 43 seconds Admin [Admin] Online for 0 hours 34 minutes 8 seconds

Are you interested in the code? Maybe it can be implemented as an extra option so that someone can choose whether or not to show the online time.

Update: Modified it so it can be optional with an extra variable $wgWhosOnlineShowTime.


 * Sharing is caring, so it'd be lovely if you could share your modifications. :-) --Jack Phoenix (Contact) 21:18, 23 August 2015 (UTC)

OK :

WhosOnline.php:

Added at line 36:

// Showing how long a user is logged on (default false) $wgWhosOnlineShowTime = false;

WhosOnlineSpecialPage.php:

 * @modified by Dick Pluim to show online time */

if ( !defined( 'MEDIAWIKI' ) ) { exit( 1 ); }

class PagerWhosOnline extends IndexPager { function __construct { parent::__construct; $this->mLimit = $this->mDefaultLimit; }

function getQueryInfo { global $wgWhosOnlineShowAnons;

return array(			'tables' => array( 'online' ),			'fields'  => array( 'username' ,'timestamp' ),			'options' => array( 'ORDER BY' => 'username' ),			'conds'   => $wgWhosOnlineShowAnons					? array					: array( 'userid != 0' )		); }

// use classical LIMIT/OFFSET instead of sorting by table key function reallyDoQuery( $offset, $limit, $descending ) { $info = $this->getQueryInfo; $tables = $info['tables']; $fields = $info['fields']; $conds = isset( $info['conds'] ) ? $info['conds'] : array; $options = isset( $info['options'] ) ? $info['options'] : array;

$options['LIMIT'] = intval( $limit ); $options['OFFSET'] = intval( $offset );

$res = $this->mDb->select( $tables, $fields, $conds, __METHOD__, $options );

return new ResultWrapper( $this->mDb, $res ); }

function getIndexField { return 'username'; // dummy }

function formatRow( $row ) { global $wgWhosOnlineShowTime ; ## seems that timestamp in table online is 1 hour off, so ... #date_default_timezone_set( 'UTC' ); $current_time = gmdate ( 'YmdHis', time );

$start_date = new DateTime($row->timestamp); $since_start = $start_date->diff(new DateTime($current_time));

$logged_on_time = 'Online for '. $since_start->h.' hours '. $since_start->i.' minutes '. $since_start->s. ' seconds' ;

$userPageLink = Title::makeTitle( NS_USER, $row->username )->getFullURL; if ( $wgWhosOnlineShowTime ) {

return '>'. htmlspecialchars( $row->username ). ' '. htmlspecialchars( $logged_on_time ). ''; }               else {  return '>'. htmlspecialchars( $row->username ). ''; }

}

// extra methods function countUsersOnline { wfProfileIn( __METHOD__ );

$row = $this->mDb->selectRow(			'online',			'COUNT(*) AS cnt',			'userid != 0',                       'timestamp',			__METHOD__		); $users = (int) $row->cnt;

wfProfileOut( __METHOD__ );

return $users; }

function getNavigationBar { global $wgContLang,$wgLang;

$query = ''; $offset = $this->mOffset; $limit = $this->mLimit; $link = $wgContLang->specialpage( 'WhosOnline' ); $atend = $this->countUsersOnline < ( $this->mLimit + $this->mOffset ); // show next link $query = wfCgiToArray( '' ); if( is_object( $link ) ) { $title = $link; } else { $title = Title::newFromText( $link ); if( is_null( $title ) ) { return false; }               }

return $wgLang->viewPrevNext(                       $title,                        $offset,                        $limit,                        $query,                        $atend); } }

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',                       'timestamp', 			__METHOD__		); $guests = (int) $row->cnt;

wfProfileOut( __METHOD__ );

return $guests; }

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

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

$this->setHeaders;

$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] ); }			}		}

$body = $pager->getBody;

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

$wgOut->addHTML( '' . $body . '' ); } }

Update: I also removed the deletion of the entry db->delete etc.

And when you go for the first time to the Who's Online specialpage it will be empty. When refreshing it will show f.e. you as being logged on for a few seconds where you might have been online for a while.

Fatal error running update.php on V1.5.0
I'm running MW v1.25.1, and just installed WhosOnline v1.5.0 using the new startup line. However, running /mw-config/ produces:
 * Fatal error: Uncaught exception 'Exception' with message '/home/sanders4/public_html/wiki/extensions/WhosOnline/extension.json does not exist!' in /home/sanders4/public_html/wiki/includes/registration/ExtensionRegistry.php:79 Stack trace:
 * 1) 0 /home/sanders4/public_html/wiki/includes/GlobalFunctions.php(181): ExtensionRegistry->queue('/home/sanders4/...')
 * 2) 1 /home/sanders4/public_html/wiki/LocalSettings.php(390): wfLoadExtension('WhosOnline')
 * 3) 2 /home/sanders4/public_html/wiki/includes/WebStart.php(124): require_once('/home/sanders4/...')
 * 4) 3 /home/sanders4/public_html/wiki/index.php(38): require('/home/sanders4/...')
 * 5) 4 /home/sanders4/public_html/wiki/index.php5(26): require('/home/sanders4/...')
 * 6) 5 {main} thrown in /home/sanders4/public_html/wiki/includes/registration/ExtensionRegistry.php on line 79

The error is correct, extension.json does in deed not exist. WmBliss (talk) 02:51, 12 October 2015 (UTC)


 * I got this error too. I fixed it using the old require_once string:  --5.150.135.196 09:46, 20 November 2015 (UTC)

Time?
I do not find information about how long (after the last user activity?) the display will be held? -- Manorainjan  22:56, 6 February 2017 (UTC)

How to make a horizontal list?
The vertical list is inconvenient when there are a lot of users.

Flag of country
Hello. Gréât extension for the security in réal Time. How to do for a display with the ip and the flag of the country. Is it possible? Thanks

Bug? Shows Logged Out Users.
I'm seeing logged out users for quite some time (maybe hours)

any fix?