Extension talk:Whos online

Blank Page
After installation, adding the just results in a blank page for me (kills MediaWiki 1.11). Other extensions that I'm using: CategoryTree, LabeledSectionTransclusion, ParserFunctions, Treeview (version 3.6.2, 2007-09-02). SeanFromIT 19:48, 12 December 2007 (UTC)

is there any way to show a list of users that are online?

Andy

'Refreshing' the WhosOnline results
The extension works fine but, it will not show the current status because the page that should show the status is cached. When I save that page again it is rerenderen and the correct status is shown. What I now did is set $wgEnableParserCache = false; in includes/DefaultSettings.php. surely there must be a less 'drastic' way to do this for only 1 page.

Vic

Installation step 3
Hello, I'm a bit of a n00b when it comes to these things. Installing an extension, OK, editing LocalSettings.php, fine, but editing the DB, eek! Is the PHP script as an alternative to the first part, or are they both necessary?

What exactly should I be looking for to edit the DB? In my web interface of my webhost it has links to 'restore', 'modify' and 'delete' the DB. It also has this advice: mysql -u username -ppassword -h hostname databasename for accessing a DB from the commandline. Is this what I should be doing? Any advice? :) cheers, pfctdayelise 11:32, 1 August 2006 (UTC)


 * The part labelled as "You can use the following PHP script for installing" is another users suggestion on how to not worry about building the new table manually but to have MediaWiki do it for you. I have not reviewed or tested the code at this stage and it is an alternative.  It will make the installation a lot easier for new users if MediaWiki does it for you, so I will be adding the code to the actual installation process.  If you give me 24 hours or so, I should be able to update the documentation appropriately. -- (Smcnaught) 15:33, 1 August 2006 (UTC).


 * OK that would be awesome. Thanks, I'll wait. :) --pfctdayelise 02:50, 2 August 2006 (UTC)
 * I have updated the docs. I hope that it helps you. (Smcnaught) 02:36, 4 August 2006 (UTC)

Maybe it would be a good idea to integrate the installation into function renderWhosOnline( $input ). If the first SQL-query (DELETE) fails, call an install function. Yet this would require the wiki user to have CREATE rights.

$username = $wgUser->getName; $tblname = $wgDBprefix."online";

$sql = "DELETE from $tblname WHERE username = '$username' OR timestamp < '$old' "; $db =& wfGetDB( DB_WRITE ); if ( $db !== false ) { $ret = $db->query( $sql, '', true ); } else { $ret = false; } if ( false === $ret ) { $sql = "CREATE TABLE $tblname (     `userid` int(5) NOT NULL default '0',      `username` varchar(255) NOT NULL default ,      `timestamp` varchar(255) NOT NULL default       ) TYPE=MyISAM "; $ret = wfQuery($sql, DB_WRITE, ""); }

$sql = "INSERT INTO $wgDBprefix"."online (userid,username,timestamp) VALUES ('$userid','$username','$now')"; -- Xypron 05:52, 4 August 2006 (UTC)
 * Has this been tested in your environment Xypron? (Smcnaught) 16:48, 4 August 2006 (UTC)

Allowing wikiuser to have CREATE access
Here is how you can configure your wikiuser to have CREATE access to your wikidb: [user@server extensions]$ mysql -u root -p wikidb Enter password: mysql> REVOKE ALL PRIVILEGES ON *. * FROM 'wikiuser'@'localhost'; mysql> REVOKE GRANT OPTION ON *. * FROM 'wikiuser'@ 'localhost'; mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON *. * TO 'wikiuser'@ 'localhost'; -- (Smcnaught) 17:13, 4 August 2006 (UTC) - I am also available on irc.chekmate.org #MediaWiki

Testing...
Hmm. I put the script in my extensions folder and ran it (well, actually just put its address in my web browser. I think that's the same thing?). It told me this: Warning: array_push [function.array-push]: First argument should be an array in [...]/extensions/talkright.php on line 23 CREATE TABLE bb_online ( `userid` int(5) NOT NULL default '0', `username` varchar(255) NOT NULL default , `timestamp` varchar(255) NOT NULL default  ) TYPE=MyISAM Notice: Table bb_online created. in [...]/extensions/build_whois.php on line 26

So I'm kinda confused. It gave me a warning about an unrelated extension. (Talkright_extension)

I put &lt;whosonline&gt; on a page in my wiki to see if it worked anyway. No dice. :) It said this:

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:

(SQL query hidden)

from within function "". MySQL returned error "1146: Table 'brunswickbug.bb_cur' doesn't exist ([...])". So, there you go, I guess it didn't create it, or something weird happened...

any ideas? pfctdayelise 13:00, 4 August 2006 (UTC)
 * This was a command line script, not one to be executed by the browser.

[user@server extensions]$ php build_whois.php
 * If you execute this script from the command line it should work. I would attempt this first, but I am going to be adding Xypron's recommendation to place the table build within the actual script. (Smcnaught) 16:54, 4 August 2006 (UTC) - I am also available on irc.chekmate.org #MediaWiki

2 tags on 1 page gives error
Thanks for the nice extention.

I have a problem when putting 2 tags on one page like:

This will geve me the following result �UNIQ5b2252c1f9be61f-whosonline-4754b5f228bd3c2200000001-QINU

Guests: 0 Registered: 1 (Slagter )

Any idea on what might cause this? 80.126.111.189 14:31, 10 August 2006 (UTC)


 * Thanks but this does not seem to solve the problem. What I did next was just to put only a return $wgOut->parse('TEST'); in the function renderWhosOnline just after the line $timeperiod = 3600; # number of seconds. Still the strange output. I suspect the $wgOut->parse to be the problem.
 * I am using MediaWiki 1.7.1 and php5.1.2 on Ubuntu Linux. Since I am not a programmer this is way to deep in MediaWiki source code. I think I just have to stick to only use only one  element per page. 80.126.111.189 08:46, 15 August 2006 (UTC)

Problem when using on same page as Calendar extension
�UNIQ86c6cec5b91c52b-calendar-25468dc92042a4c000000001-QINU

Same problem as above but it seems to happen on any page using multiple extensions.

I have the same problem with but I use one  only. Funny thing: I did my own extension for 1.7.x which worked fine till now. When I updated yesterday 1.8.3 to 1.10.1 both extensions worked fine, first(besides the php warnings, see last comment on this page). When I today restarted the server I suddenly recieve this  and   for the 2 extensions. Tried to remove one, but still have the problems with only one extension left on the page. Any ideas, please? Thanks a lot!
 * --PyroM 08:20, 6 September 2007 (UTC)

table "wiki_online" not updating
I don't know if I just never noticed it or what, but I recently upgraded from the old version (the one that didn't show you who was online) of this extension to the new version. Now it seems to always just show me as logged on. I checked the SQL tables and found "wiki_online" and I was the only entry in there. I deleted it and had everyone log back on, the only entry that repopulated was my username. Does anyone know how this can be fixed or if this is normal? I think it has something to do with this extension. Thanks!

Update
Upon closer inspection, it seems as though if I log in with a different account on my PC it updates the table ok, but anyone else using a different PC it doesn't. I've even had them log out, clear cookies/cache, and log back in...still no updates to the table. Any ideas?


 * The timeperiod is presently set to 3600 seconds (1 hour), thus it will show how many unique users have accessed the site within the last hour. The script is not meant to be accurate to the minute as a user may be online and working on creating a page but not cause any updates to the site for a long period.  It sounds like the issue you are experiencing is by design. :-) (Smcnaught 04:55, 13 October 2006 (UTC))

Update for MediaWiki 1.9.0
When using Whos Online extension, the page gives error. It seems that the line "$ti = wfStrencode($wgTitle->getDBkey);" is a problem. The function wfStrencode is not defined as global function in MDW 1.9.0 (and 1.9.1). -- Paul.D

Yes, I can confirm - same qith wfQuery. In support forums of MediaWiki I was informed that these methods are very obsolete and have been removed in 1.9.0. In 1.8.3 all was fine. I was suggested to use "methods on database objects" instead. Since I am not a MediaWiki programmer I don't know what that means. Can please anybody help? I do not update my wiki from 1.8.3 to 1.9.0 because of this highly needed extension. Thanks a lot -- 84.191.1.166 10:22, 21 January 2007 (UTC) Pyro

mm.. to avoid such errors you may do the following... insert require_once ("includes/DatabaseFunctions.php"); require_once ("extensions/WhosOnline.php"); instead of require_once ("extensions/WhosOnline.php"); as described in 6.3 chapter of installation

DatabaseFunctions.php is not included by default and was written for back-compatibility

Update for MediaWiki 1.10?
Is it possible to get an update for version 1.10? Many thanks in advance. I really like this MediaWiki extension. /Minken


 * Ditto. Upgraded to 1.10 and this extension is not functional.  --PurplePopple 03:41, 9 July 2007 (UTC)

Undefined variable $Userlist
$Userlist is used without initialization. Fixed in article --212.64.224.249 17:52, 22 May 2007 (UTC)

Upgrade for MediaWiki 1.10
I (with the help of User:Nikerabbit) made the code work with MediaWiki 1.10 and 1.11 as well.

I think it is time to update the code. However, I'm not sure what is the best optino to also keep the code for the previous version (and whether we should keep it at all)? Huji 18:26, 1 September 2007 (UTC)


 * Some fixes - the extension is &lt;whosonline&gt; - not &lt;rss&gt;. Also removed the closing tag per 23531. -- Sayuri 18:30, 1 September 2007 (UTC)


 * The new and improved extension works great for me. Thanks a lot guys! 67.103.106.172 21:39, 1 September 2007 (UTC)

Thanks a lot, but some php warnings
Thanks a lot, the last code and the including of the DatabaseFunctions made it run again on 1.10.1 But, I get some PHP warnings which is very annoying in the page header ;)

Is there a way to avoid this, please? Thanks a lot
 * --PyroM 08:20, 6 September 2007 (UTC)

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name]. If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\WOS\www\wikiroot\extensions\WhosOnline.php on line 97

Here's an update that works for MediaWiki 1.11.0
- Now the function works without adding. It will simply show up at the bottom of pages.

Updated by Zedomax

WhosOnline Mediawiki extension version 2.0

Here's an update to the original WhosOnline MediaWiki extension.

Code:

<?php
 * 1) WhosOnline Mediawiki extension version 2.0
 * 2) originally by Shannon McNaught 22.06.2006
 * 3) updated for MediaWiki 1.11.0 by Max Lee 17.11.2007
 * 4) - version 2.0 updated by Max Lee
 * 5) - added wgHook to automatically add Who's Online at the bottom of pages.
 * 6) - version 2.0.1 updated by Chad MacDonald
 * 7) - added require_once ("includes/DatabaseFunctions.php");  to include legacy database functions
 * 1) - version 2.0 updated by Max Lee
 * 2) - added wgHook to automatically add Who's Online at the bottom of pages.
 * 3) - version 2.0.1 updated by Chad MacDonald
 * 4) - added require_once ("includes/DatabaseFunctions.php");  to include legacy database functions


 * 1) updated version website: http://zedomax.com/wiki
 * 2) original website: http://www.chekmate.org/wiki/index.php/Projects


 * 1) Installation:
 * 2)  * Add the follwing table to your wiki database through myPhpAdmin
 * 3)         CREATE TABLE `online` (
 * 4)      `userid` int(5) NOT NULL default '0',
 * 5)      `username` varchar(255) NOT NULL default '',
 * 6)      `timestamp` varchar(255) NOT NULL default ''
 * 7)      ) TYPE=MyISAM;
 * 8)  * put this file (WhosOnline.php) into the extension directory of your mediawiki installation
 * 9)  * add the following to the end of LocalSettings.php: include("extensions/WhosOnline.php");
 * 10)  * add the following to the end of LocalSettings.php: require_once ("includes/DatabaseFunctions.php");
 * 11) Tested with MediaWiki 1.11.0
 * 1) Tested with MediaWiki 1.11.0

$wgHooks['BeforePageDisplay'][] = array("renderWhosOnline");

function renderWhosOnline( &$out) { global $wgUser, $wgDBprefix,$wgVersion,$wgOut; global $wgOutputEncoding;
 * 1) parser hook callback function

// ###### INVALIDATE CACHE ###### global $wgTitle; $ts = mktime; $now = gmdate("YmdHis", $ts + 120); $ns = $wgTitle->getNamespace; $ti = wfStrencode($wgTitle->getDBkey); $version = preg_replace("/^([1-9]).([1-9]).*/", "\\1\\2", $wgVersion); $sql = "UPDATE page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'"; //yyif ($version>14) $sql = "UPDATE $wgDBprefix"."page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'"; //else            $sql = "UPDATE $wgDBprefix"."cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'"; wfQuery($sql, DB_WRITE, "");

$timeperiod = 3600; # number of seconds

$DefaultEncoding = "ISO-8859-1"; $DisableCache = true; $ts = mktime; $now = gmdate("YmdHis", $ts); $old = gmdate("YmdHis", $ts-$timeperiod); $userid = $wgUser->getID; $username = $wgUser->getName; $tblname = "online";

$sql = "DELETE from online WHERE username = '$username' OR timestamp < '$old' "; $db =& wfGetDB( DB_WRITE ); if ( $db !== false ) { $ret = $db->query( $sql, '', true ); } else { $ret = false; } if ( false === $ret ) { $sql = "CREATE TABLE $tblname (     `userid` int(5) NOT NULL default '0',      `username` varchar(255) NOT NULL default ,      `timestamp` varchar(255) NOT NULL default       ) TYPE=MyISAM "; $ret = wfQuery($sql, DB_WRITE, ""); }

$sql = "INSERT INTO online (userid,username,timestamp) VALUES ('$userid','$username','$now')"; $output = $sql; wfQuery($sql, DB_WRITE, ""); $sql = "select * from online where userid = 0"; $dbr =& wfGetDB( DB_SLAVE );

$res = $dbr->query ( $sql ) ; $guests = $dbr->numRows($res) + 0; $sql = "select username from online where userid != 0"; $res = $dbr->query ( $sql ) ; $registered = $dbr->numRows($res) + 0; while( $row = $dbr->fetchObject( $res ) ){ $Userlist .= "".$row->username." "; }

$dbr->freeResult( $res );

$output = "Guests: $guests Registered: $registered ($Userlist)";

$output = $wgOut->parse($output); $out->mBodytext.=$output; return $out; }

?>

MW 1.11, WhosOnline + Database Functions
... is not working. I'm receiving a error that, when using in conjunction with DatabaseFunctions, a certain table (wikidb.page) does not exist. I've googled it, but found nothing that's conclusive. And before I check the tracker, I wanted to know if anyone knows about this error. 66.168.102.87 06:38, 14 December 2007 (UTC)

Actually, i have the same problem as well. As you mentioned, i also searched google for an answer to no avail. A solution would be nice, i loved this extention in my earlier version wiki. Would be nice to have it again. As an after thought, like the user above, mine looked for the same table but under a different name. The prefix was the name of the database, not the page table prefix. --87.245.39.229 12:52, 14 December 2007 (UTC)