Not signed in (Sign In)

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthordknowles
    • CommentTimeMay 3rd 2006
     # 1
    This extension will add a “Who’s Online� Menu option to the control panel, allowing users to see when other users are signed in and active on the boards. Please note that this extension adds a few more database queries and updates, so this could potentially degrade the performance of your server. This perfomance hit should be negligible for a reasonable number of users.
    •  
      CommentAuthorWanderer
    • CommentTimeMar 5th 2007
     # 2
    The Extensions update breaks at the apostrophe with this extension...

    Who's Online 1.1
    CheckingForUpdates

    Error: Who'sOnline|[UNKNOWN]ExtensionStatusUnknown

    Posted: Monday, 5 March 2007 at 8:26PM (AEDT)

    •  
      CommentAuthorMark
    • CommentTimeMar 5th 2007
     # 3
    This can be fixed at the addon site level for the time being, but I'm going to implement a fix for the core as well so punctuation is acceptable.
    •  
      CommentAuthorMark
    • CommentTimeMar 6th 2007 edited
     # 4
    I've fixed this in subversion. I'm going to wait a day or two before releasing 1.1.2 in case some other things come up.
    • CommentAuthordejitaru
    • CommentTimeMar 6th 2007
     # 5
    is this also the reason why I cannot enable this plugin after upgrading to vanilla 1.1? Its listed in the extensions list and I can check it but it does not enable.
    • CommentAuthordejitaru
    • CommentTimeMar 6th 2007
     # 6
    nevermind replaced the two files anyhow and it works dandy.
    •  
      CommentAuthorskube
    • CommentTimeMar 6th 2007
     # 7
    Just wondering, anyone know of an easy way to have the names listed inline, rather than each per line? Trying to save space...
    •  
      CommentAuthorMr Do
    • CommentTimeMar 12th 2007 edited
     # 8
    Yes I have. It was kinda hard, not knowing this system, but i figured it out. Don know if u consider this method a "hack", but it works.

    1. Open the "extentions/WhosOnline/default.php" file
    2. On line 150 (just before the line that says $Panel->AddList($ListName);
    add the following line : $Panel->AddString("<div id='onlinenow'>",500);
    3. On the next line change it to:$Panel->AddList($ListName,501);
    4. 30 lines down (before the last curly bracket)
    add this line: $Panel->AddString("</div>",502);
    5. Save and close this file.
    6. Create a "style.css" file in this extion folder and open it. Put this code there:
    #onlinenow ul li ul {
    overflow:hidden;
    }
    #onlinenow ul li ul li {
    width:auto;
    margin-right:4px;
    float:left;
    }

    7. Save the file.

    Thats it.

    Hope this is what u wanted
    •  
      CommentAuthorMr Do
    • CommentTimeMar 13th 2007 edited
     # 9
    Update! I found out how to add style in an extention (been reading through other ppls extentions alot to try to learn.. )


    $Head->AddStyleSheet('extensions/WhosOnline/style.css');

    is the way. Just add it on the start of extentions/WhosOnline/default.php and put the style on point 6 in a style.css file and put it the same folder..

    To the original poster / creater of this. Maybe you could incorporate this feature in the original with a setting in a config.php file. For instance a constant that says true or false; use same line format. If the original creater is inactive, I could clean up my code and make a newer version of this, but I dont wanna replace or add to with out permission..
  1.  # 10
    When I click the download link above, the file that is downloaded still says it's version 1.1 of WhosOnline in the code. When I upload it to the server, the updates page still shows it's an old version, not 1.2.
    •  
      CommentAuthorMr Do
    • CommentTimeMar 14th 2007
     # 11
    yea i get that too. my guess is he forgot to update the version number in the default.php file :)
    •  
      CommentAuthorWanderer
    • CommentTimeMar 14th 2007
     # 12
    They are both exactly the same apart from the version number, just change the version in your default file to 1.2 if you want.

    Posted: Wednesday, 14 March 2007 at 6:56PM (AEDT)

  2.  # 13
    LOL OK. Why an update with no...er...update?

    Anyway, I changed the version number in the default file and now my extensions all show to be the current version. Thanks. :)
    •  
      CommentAuthorLussumo Bot
    • CommentTimeMar 14th 2007 edited
     # 14
    Uploaded version 1.2 of Who's Online with the correct version number.
    •  
      CommentAuthoricouto
    • CommentTimeMar 14th 2007 edited
     # 15
    It would be nice to have the capacity to see Who's Online connected to a certain permission level - ie., I would like to allow my users to see Who's Online, but not the anonymous guests.

    It might also be nice to be able to place the list of users at the middle/bottom of the sidepanel, rather than at the top!
    •  
      CommentAuthorGauzy
    • CommentTimeMar 15th 2007
     # 16
    icouto - this doesn't display if you are not logged in
    •  
      CommentAuthoricouto
    • CommentTimeMar 15th 2007
     # 17
    @Gauzy: doh! How silly do I feel... Bad example...

    It might be nice, for instance, to let 'administrators' see who's online, but not general users.
    •  
      CommentAuthorGauzy
    • CommentTimeMar 15th 2007
     # 18
    @icouto - ah, yeah, i see what you mean now. not sure how to go about doing that, i imagine it's possible, but outside my realm of expertise.
  3.  # 19
    If you look in the default.php file for this:
    if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php"))
    && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) {
    You could change it to
    if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php"))
    && $Context->Session->UserID > 0 && $Context->Session->RoleID == 4 && !$Context->Session->User->Preference("HideWhosOnline")) {
    and it'l only display for users whose role ID is 4 (default admin role, you might need to change it)
    •  
      CommentAuthorMr Do
    • CommentTimeMar 16th 2007 edited
     # 20
    important update on my hack .. I edited the original text. so look there.. the point is to use positioning on both addstring and addpanel..

    btw.. Is anyone using it?
    • CommentAuthorabcpeanuts
    • CommentTimeMar 20th 2007
     # 21
    Can I ask a question here related to this add-on?

    I just upgraded my forum to 1.1.2

    Now, for some reason, it always says I have tons of guests. It may say 54 guests one minute, then 84 guests the next minute. I know I don't have that many people there. Is there some sort of error going on? Thanks.
    •  
      CommentAuthorsjeeps
    • CommentTimeMar 20th 2007
     # 22
    Hi,

    I still can't see any guest count!

    Only members name when they're signed in, so who to turn it so it show's guest as well as members?

    Thanks
    • CommentAuthorgriderhill
    • CommentTimeMar 21st 2007
     # 23
    This addon is not workin for me. Back on March 6 there was a post about modifying 2 files, but now I don't see anything about what those files are.

    I have vanilla 1.1.1, and whosonline 1.2?

    I appreciate the help.
    • CommentAuthorgriderhill
    • CommentTimeMar 21st 2007
     # 24
    OK the upgrade to 1.2 fixed it all.. I thought I had done that.. but posting here I noticed not.... Whois is very important for my application...thanks for the work.
    •  
      CommentAuthorGauzy
    • CommentTimeMar 21st 2007
     # 25
    anybody else getting the bug that everything is displayed as being active "1 hour ago" in the title?
    • CommentAuthorabcpeanuts
    • CommentTimeMar 24th 2007
     # 26
    This seems to have fixed itself, which leads me to believe it was spambots. Who knows!
    •  
      CommentAuthorsjeeps
    • CommentTimeApr 8th 2007
     # 27
    Hi, I'm still having a problem to get the user's names listed inline, rather than each per line and Mr Do hack above didn't seem to work!

    Any thoughts?
    Thanks.
    •  
      CommentAuthorMr Do
    • CommentTimeApr 8th 2007 edited
     # 28
    how doesnt it work? it works for me..

    I think the problem is that I forgot to give you the line to add the style file? just put that css style into a css file allready active, at the bottom of vanilla.css in the styles folder for example..
    •  
      CommentAuthorsjeeps
    • CommentTimeApr 8th 2007
     # 29
    Ok... here is the default.php:

    <?php
    /*
    Extension Name: Who's Online
    Extension Url: http://www.thirty5.net/code/vanilla/whosonline/
    Description: Adds a "who's online" list to the panel.
    Version: 1.2
    Author: David Knowles, Julien Cassignol, Michael Schieben
    Author Url: mailto:dknowles2@gmail.com

    Additional Author: Michael Schieben - michael@twoantennas.com (Adaption to Vanilla 1.0)

    */
    $Context->Dictionary["MenuOptions"] = "Menu Options";
    $Context->Dictionary["HideWhosOnline"] = "Hide the \"Who's Online\" panel";
    $Context->Dictionary["Phantom"] = "Hide my username from the \"Who's Online\" panel";


    class WhosOnline {
    var $Name;
    var $Context;

    function WhosOnline(&$Context) {
    $this->Name = "WhosOnline";
    $this->Context = &$Context;
    }

    function GetWhosOnline() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("User", "u");
    $s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences"), "u");
    $s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);
    $result = $this->Context->Database->Select($s, $this->Name, "GetRecentUsers", "An error occurred while attempting to retrieve the requested information.");
    if ($this->Context->Database->RowCount($result) == 0) {
    return NULL;
    } else {
    $my_array = array();
    while ($rows = $this->Context->Database->GetRow($result)) {
    if ($rows["Preferences"]) {
    $settings = unserialize($rows["Preferences"]);
    if (array_key_exists("Phantom", $settings))
    $phantom = ForceBool($settings["Phantom"], 0);
    else
    $phantom = false;
    } else {
    $phantom = false;
    }
    array_push($my_array, array("Name" => $rows["Name"], "UserID" => $rows["UserID"],
    "DateLastActive" => $rows["DateLastActive"], "Phantom" => $phantom));
    }
    return $my_array;
    }
    }

    function GetGuestCount() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("IpHistory", "i");
    $s->AddSelect("IpHistoryID", "i", "GuestCount", "COUNT");
    $s->AddWhere("i", "UserID", "", 0, "=");
    $s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 1 MINUTE)", ">=", 'and', NULL, 0);
    $result = $this->Context->Database->Select($s, $this->Name, "GetGuestCount", "An error occurred while attempting to retrieve the requested information.");
    $row = $this->Context->Database->GetRow($result);
    return $row["GuestCount"];
    }

    function GetNextIpLetter($my_ip) {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("IpHistory", "i");
    $s->AddSelect("RemoteIp", "i");
    $s->AddWhere("i", "UserID", "", 0, "=");
    $s->AddWhere("i", "RemoteIp", "", "$my_ip([a-z])*$", "regexp");
    $s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 30 MINUTE)", ">=", 'and', NULL, 0);
    $s->AddOrderBy("RemoteIp", "i", "desc");
    $s->AddLimit(0, 1);
    $result = $this->Context->Database->Select($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");

    if ($this->Context->Database->RowCount($result) > 0) {
    $row = $this->Context->Database->GetRow($result);
    if (preg_match("/([a-z])+$/", $row["RemoteIp"], $ip_letter))
    return ++$ip_letter[0];
    else
    return "a";
    } else {
    return "";
    }
    }

    function GetIpHistoryID($my_ip) {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("IpHistory", "i");
    $s->AddSelect("IpHistoryID", "i");
    $s->AddWhere("i", "UserID", "", 0, "=");
    $s->AddWhere("i", "RemoteIp", "", $my_ip, "=");
    $s->AddOrderBy("IpHistoryID", "i", "desc");
    $s->AddLimit(0, 1);
    $result = $this->Context->Database->Select($s, $this->Name, "GetIpHistoryID",
    "An error occurred while attempting to retrieve the requested information.");
    $row = $this->Context->Database->GetRow($result);
    return $row["IpHistoryID"];
    }

    function UpdateDateLastActive() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");

    if (isset($_COOKIE['IpHistoryID'])) {
    $s->SetMainTable("IpHistory", "i");
    $s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");
    $this->Context->Database->Delete($s, $this->Name, "UpdateDateLastActive", "An error occurred while deleting guest profile");
    setcookie('IpHistoryID', '', time() - 3600);
    }
    $s->Clear();
    $s->SetMainTable("User", "u");
    $s->AddFieldNameValue("DateLastActive", "now()", 0);
    $s->AddWhere("u", "UserID", "", $this->Context->Session->UserID, "=");
    $result = $this->Context->Database->Update($s, $this->Name, "UpdateDateLastActive", "An error occurred while updating your account.");
    }

    function UpdateGuestLastActive() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    if (isset($_COOKIE['IpHistoryID'])) {
    $s->Clear();
    $s->SetMainTable("IpHistory", "i");
    $s->AddFieldNameValue("DateLogged", "now()", 0);
    $s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");
    $result = $this->Context->Database->Update($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
    } else {
    $my_ip = GetRemoteIp(1);
    $ip_letter = $this->GetNextIpLetter($my_ip);
    $s->Clear();
    $s->SetMainTable("IpHistory", "i");
    $s->AddFieldNameValue("UserID", 0);
    $s->AddFieldNameValue("RemoteIp", $my_ip . $ip_letter);
    $s->AddFieldNameValue("DateLogged", "Now()", 0);
    $this->Context->Database->Insert($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
    setcookie('IpHistoryID', $this->GetIpHistoryID($my_ip . $ip_letter));
    }
    }

    }

    $WhosOnline = $Context->ObjectFactory->NewContextObject($Context, "WhosOnline");

    if (!in_array($Context->SelfUrl, array("signin.php", "leave.php", "post.php", "passwordrequest.php", "passwordreset.php"))) {
    if ($Context->Session->UserID > 0)
    $WhosOnline->UpdateDateLastActive();
    else
    $WhosOnline->UpdateGuestLastActive();
    }

    if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php"))
    && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) {
    $ListName = $Context->GetDefinition("Who's Online");
    $Panel->AddList($ListName);
    $online_list = $WhosOnline->GetWhosOnline();
    $guest_count = $WhosOnline->GetGuestCount();
    $phantom_count = 0;
    if ($online_list) {
    foreach ($online_list as $name) {
    if ($name["Phantom"]) {
    $phantom_count++;
    }
    if (!$name["Phantom"] || !isset($name["Phantom"]) || $Context->Session->User->Permission("PERMISSION_WHOS_PHANTOM")) {
    $TimePast = TimeDiff($Context, unixtimestamp($name["DateLastActive"]));
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
    }
    }
    if ($phantom_count > 0) {
    $phantom_string = "$phantom_count phantom user";
    if ($phantom_count > 1)
    $phantom_string .= "s";
    $Panel->AddListItem($ListName,'','',$phantom_string);
    }
    if ($guest_count > 0) {
    $guest_string = "$guest_count guest";
    if ($guest_count > 1)
    $guest_string .= "s";
    $Panel->AddListItem($ListName,'','',$guest_string);
    }
    } else {
    $Panel->AddListItem($ListName,'','',"Nobody's online.");
    }
    }

    // Add the Who's Online setting to the forum preferences form
    if ($Context->SelfUrl == "account.php" && $Context->Session->UserID > 0) {
    $PostBackAction = ForceIncomingString("PostBackAction", "");
    if ($PostBackAction == "Functionality") {
    function PreferencesForm_AddWhosOnlinePreference(&$PreferencesForm) {
    $PreferencesForm->AddPreference("MenuOptions", "HideWhosOnline", "HideWhosOnline", 0);
    $PreferencesForm->AddPreference("MenuOptions", "Phantom", "Phantom", 0);
    }

    $Context->AddToDelegate("PreferencesForm",
    "Constructor",
    "PreferencesForm_AddWhosOnlinePreference");
    }
    }


    ?>

    Could you please point out where to hack the code? Thank.
    •  
      CommentAuthorMr Do
    • CommentTimeApr 8th 2007 edited
     # 30
    Look for the//////////// lines, its the code between those.
    <?php
    /*
    Extension Name: Who's Online
    Extension Url: http://www.thirty5.net/code/vanilla/whosonline/
    Description: Adds a "who's online" list to the panel.
    Version: 1.2
    Author: David Knowles, Julien Cassignol, Michael Schieben
    Author Url: mailto:dknowles2@gmail.com

    Additional Author: Michael Schieben - michael@twoantennas.com (Adaption to Vanilla 1.0)

    */
    class WhosOnline {
    var $Name;
    var $Context;

    function WhosOnline(&$Context) {
    $this->Name = "WhosOnline";
    $this->Context = &$Context;
    }

    function GetWhosOnline() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("User", "u");
    $s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences"), "u");
    $s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);
    $result = $this->Context->Database->Select($s, $this->Name, "GetRecentUsers", "An error occurred while attempting to retrieve the requested information.");
    if ($this->Context->Database->RowCount($result) == 0) {
    return NULL;
    } else {
    $my_array = array();
    while ($rows = $this->Context->Database->GetRow($result)) {
    if ($rows["Preferences"]) {
    $settings = unserialize($rows["Preferences"]);
    if (array_key_exists("Phantom", $settings))
    $phantom = ForceBool($settings["Phantom"], 0);
    else
    $phantom = false;
    } else {
    $phantom = false;
    }
    array_push($my_array, array("Name" => $rows["Name"], "UserID" => $rows["UserID"],
    "DateLastActive" => $rows["DateLastActive"], "Phantom" => $phantom));
    }
    return $my_array;
    }
    }

    function GetGuestCount() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("IpHistory", "i");
    $s->AddSelect("IpHistoryID", "i", "GuestCount", "COUNT");
    $s->AddWhere("i", "UserID", "", 0, "=");
    $s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 1 MINUTE)", ">=", 'and', NULL, 0);
    $result = $this->Context->Database->Select($s, $this->Name, "GetGuestCount", "An error occurred while attempting to retrieve the requested information.");
    $row = $this->Context->Database->GetRow($result);
    return $row["GuestCount"];
    }

    function GetNextIpLetter($my_ip) {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("IpHistory", "i");
    $s->AddSelect("RemoteIp", "i");
    $s->AddWhere("i", "UserID", "", 0, "=");
    $s->AddWhere("i", "RemoteIp", "", "$my_ip([a-z])*$", "regexp");
    $s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 30 MINUTE)", ">=", 'and', NULL, 0);
    $s->AddOrderBy("RemoteIp", "i", "desc");
    $s->AddLimit(0, 1);
    $result = $this->Context->Database->Select($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");

    if ($this->Context->Database->RowCount($result) > 0) {
    $row = $this->Context->Database->GetRow($result);
    if (preg_match("/([a-z])+$/", $row["RemoteIp"], $ip_letter))
    return ++$ip_letter[0];
    else
    return "a";
    } else {
    return "";
    }
    }

    function GetIpHistoryID($my_ip) {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("IpHistory", "i");
    $s->AddSelect("IpHistoryID", "i");
    $s->AddWhere("i", "UserID", "", 0, "=");
    $s->AddWhere("i", "RemoteIp", "", $my_ip, "=");
    $s->AddOrderBy("IpHistoryID", "i", "desc");
    $s->AddLimit(0, 1);
    $result = $this->Context->Database->Select($s, $this->Name, "GetIpHistoryID",
    "An error occurred while attempting to retrieve the requested information.");
    $row = $this->Context->Database->GetRow($result);
    return $row["IpHistoryID"];
    }

    function UpdateDateLastActive() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");

    if (isset($_COOKIE['IpHistoryID'])) {
    $s->SetMainTable("IpHistory", "i");
    $s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");
    $this->Context->Database->Delete($s, $this->Name, "UpdateDateLastActive", "An error occurred while deleting guest profile");
    setcookie('IpHistoryID', '', time() - 3600);
    }
    $s->Clear();
    $s->SetMainTable("User", "u");
    $s->AddFieldNameValue("DateLastActive", "now()", 0);
    $s->AddWhere("u", "UserID", "", $this->Context->Session->UserID, "=");
    $result = $this->Context->Database->Update($s, $this->Name, "UpdateDateLastActive", "An error occurred while updating your account.");
    }

    function UpdateGuestLastActive() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    if (isset($_COOKIE['IpHistoryID'])) {
    $s->Clear();
    $s->SetMainTable("IpHistory", "i");
    $s->AddFieldNameValue("DateLogged", "now()", 0);
    $s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");
    $result = $this->Context->Database->Update($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
    } else {
    $my_ip = GetRemoteIp(1);
    $ip_letter = $this->GetNextIpLetter($my_ip);
    $s->Clear();
    $s->SetMainTable("IpHistory", "i");
    $s->AddFieldNameValue("UserID", 0);
    $s->AddFieldNameValue("RemoteIp", $my_ip . $ip_letter);
    $s->AddFieldNameValue("DateLogged", "Now()", 0);
    $this->Context->Database->Insert($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
    setcookie('IpHistoryID', $this->GetIpHistoryID($my_ip . $ip_letter));
    }
    }

    }
    ///////////////////////////////////////////////////
    $Head->AddStyleSheet('extensions/WhosOnline/style.css');
    ///////////////////////////////////////////////////
    $WhosOnline = $Context->ObjectFactory->NewContextObject($Context, "WhosOnline");

    if (!in_array($Context->SelfUrl, array("signin.php", "leave.php", "post.php", "passwordrequest.php", "passwordreset.php"))) {
    if ($Context->Session->UserID > 0)
    $WhosOnline->UpdateDateLastActive();
    else
    $WhosOnline->UpdateGuestLastActive();
    }
    //, "search.php", "settings.php""account.php",
    if (in_array($Context->SelfUrl, array("categories.php", "index.php", "post.php", "comments.php"))
    && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) {
    $ListName = $Context->GetDefinition("Who's Online");
    ///////////////////////////////////////
    $Panel->AddString("<div id='onlinenow'>",500);
    $Panel->AddList($ListName,501);
    ////////////////////////////////////////
    $online_list = $WhosOnline->GetWhosOnline();
    $guest_count = $WhosOnline->GetGuestCount();
    $phantom_count = 0;
    if ($online_list) {
    foreach ($online_list as $name) {
    if ($name["Phantom"]) {
    $phantom_count++;
    }
    if (!$name["Phantom"] || !isset($name["Phantom"]) || $Context->Session->User->Permission("PERMISSION_WHOS_PHANTOM")) {
    $TimePast = TimeDiff($Context, unixtimestamp($name["DateLastActive"]));
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
    }
    }
    if ($phantom_count > 0) {
    $phantom_string = "$phantom_count phantom user";
    if ($phantom_count > 1)
    $phantom_string .= "s";
    $Panel->AddListItem($ListName,'','',$phantom_string);
    }
    if ($guest_count > 0) {
    $guest_string = "$guest_count guest";
    if ($guest_count > 1)
    $guest_string .= "s";
    $Panel->AddListItem($ListName,'','',$guest_string);
    }
    } else {
    $Panel->AddListItem($ListName,'','',$Context->Dictionary['None online']);
    }
    //////////////////////////////////
    $Panel->AddString("</div>",502);
    ////////////////////////////////
    }

    // Add the Who's Online setting to the forum preferences form
    /*
    if ($Context->SelfUrl == "account.php" && $Context->Session->UserID > 0) {
    $PostBackAction = ForceIncomingString("PostBackAction", "");
    if ($PostBackAction == "Functionality") {
    function PreferencesForm_AddWhosOnlinePreference(&$PreferencesForm) {
    $PreferencesForm->AddPreference("MenuOptions", "HideWhosOnline", "HideWhosOnline", 0);
    $PreferencesForm->AddPreference("MenuOptions", "Phantom", "Phantom", 0);
    }

    $Context->AddToDelegate("PreferencesForm",
    "Constructor",
    "PreferencesForm_AddWhosOnlinePreference");
    }
    }
    */
    ?>

    And dont forget to make a style.css file in the WhosOnline folder with this contet:#onlinenow ul li ul {
    overflow:hidden;
    }
    #onlinenow ul li ul li {
    width:auto;
    margin-right:4px;
    float:left;
    }
    •  
      CommentAuthorsjeeps
    • CommentTimeApr 8th 2007 edited
     # 31
    Ok thanks..
    But the "who's online" has been moved to the bottom of the panel and still each user is show on a separate line!

    So right now it's like that:

    User one
    user two
    3 guest

    And all I'm looking for is:

    user one, user two etc.
    3guest

    :)

    btw, there's a style.css file in the extension folder, thanks.

    ***Edit***
    Never mind, I've this code in my vanilla.css file:
    ol,ul,li {
    list-style:none;
    margin:0;
    padding:0;
    }
    #Panel ul li {
    width:200px !important;
    line-height:24px;
    padding:0 !important;
    }

    And I think that's what causing the problem! :(
    •  
      CommentAuthorMr Do
    • CommentTimeApr 9th 2007
     # 32
    so now it works?
    •  
      CommentAuthorsjeeps
    • CommentTimeApr 9th 2007
     # 33
    Yes thanks, it works fine.
    • CommentAuthorChimera
    • CommentTimeApr 15th 2007
     # 34
    I want to make the same mod as sjeeps, I've put the last code from Mr Do, but it´s still showing the list like user online.

    I've created the style.css but....what can I make?
    •  
      CommentAuthorØ
    • CommentTimeApr 15th 2007
     # 35
    Mr Do's hack works fine for me. Did you put style.css in the WhosOnline folder?

    I was wondering, would there be a way to add a character in order to separated users' names? Like a comma or something. It would be useful for users with a space in ther name.
    •  
      CommentAuthorMr Do
    • CommentTimeApr 15th 2007
     # 36
    sure, many ways. 1. make a small image of a comma and put it as background image no repeat on right on the #Panel ul li OR you can go into the code and hack some more, probably by changing the line $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");to$Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]).", ", "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");Notice the difference is : .", "
    • CommentAuthorChimera
    • CommentTimeApr 15th 2007
     # 37
    Yes I put the style.css and so, but.... no response from the script.
    •  
      CommentAuthorMr Do
    • CommentTimeApr 15th 2007 edited
     # 38
    @chimera: Not sure what to say budd. You need to discribe your situation better. In the whosonline folder, are there 2 files (default.php and styles.css)? Does the style file have this code it in: #onlinenow ul li ul {
    overflow:hidden;
    }
    #onlinenow ul li ul li {
    width:auto;
    margin-right:4px;
    float:left;
    }

    did you add/change all of the following 4 lines to the default.php file:$Head->AddStyleSheet('extensions/WhosOnline/style.css');
    $Panel->AddString("<div id='onlinenow'>",500);
    $Panel->AddList($ListName,501);
    $Panel->AddString("</div>",502);

    If you have still problems, whisper me an url so I can see your page
    •  
      CommentAuthorØ
    • CommentTimeApr 15th 2007 edited
     # 39
    Thanks, changing the line works fine. However, the character is displayed even if the user is the last of the list. Looks like it's a pain to change this, so for now I've put a period instead of the comma :)
    •  
      CommentAuthorMr Do
    • CommentTimeApr 15th 2007
     # 40
    clever boy :P
    • CommentAuthorgpreston
    • CommentTimeApr 27th 2007 edited
     # 41
    I was having some problems with this working nicely with Friendly URL extension. When already in the account section (http://www.fngeeks.net/vanilla/account/) and then clicking on someone's name under Who's Online, I'd recieve a 404 File Not Found Error Message because it couldn't find the URL http://www.fngeeks.net/vanilla/account/account.php?u=2

    They way I got it to work was with the following:

    Edit: Deleted code. Found out the proper way to do it.
    • CommentAuthorgpreston
    • CommentTimeApr 27th 2007 edited
     # 42
    Alright, nix that. Went and researched this a bit more and NOW I think its working... I implemented the GetUrl() function so that it would handle both systems properly... I need someone to test this on a non-Friendly URL install.

    EDIT: UPDATED AGAIN (4/30/07)

    Find:
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
    Replace with:
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), GetUrl($Context->Configuration, 'account.php', '', 'u', $name["UserID"]), NULL, "title=\"$TimePast\"");
    • CommentAuthorgpreston
    • CommentTimeApr 30th 2007
     # 43
    I just updated the above code. Sorry to keep changing things up like this.
    •  
      CommentAuthorSomo
    • CommentTimeMay 4th 2007
     # 44
    I was trying to add color depending on role to the online users' list. I tried mimicking the dojo add-on, but can't seem to do it right :( Anyone care to help?
    •  
      CommentAuthorMr Do
    • CommentTimeMay 4th 2007 edited
     # 45
    hm.. ok let me point you in the right direction. Ultimatly you should modify the getWhosOnline function to also retrieve the users role, I dont have time just now, but you need these lines:
    $q = "SELECT LUM_Role.Name FROM `LUM_User` LEFT JOIN `LUM_Role` USING (`RoleID`) WHERE UserID='".$Comment->AuthUserID."' LIMIT 1;";
    $res = mysql_query($q);
    $row = mysql_fetch_array($res);
    $role = $row[0];
    $role = str_replace(" ","",$role);
    $role = strtolower($role);

    And then, on line 163 (my version anyway), this line:
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");

    Needs to be modified to add the class containing the color, like so:
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\" class=\"$role\"");

    Note, that you will also need to add a stylesheet for each role, by following the rules given in the Dojo Role Add On.
    • CommentAuthorgpreston
    • CommentTimeMay 4th 2007
     # 46
    If you can, I'd recommend taking the time to also make those links Friendly URL compliant by using the GetUrl() function as I posted above.
    •  
      CommentAuthorSomo
    • CommentTimeMay 4th 2007 edited
     # 47
    Thanks Mr. Do! You know, I was already doing the second part right!, which makes me kind of proud because I'm no good at this. The "retrieving" part, though, I really didn't know where to start, and now the problem is that just cutting and pasting won't do. I'm guessing this first line


    $q = "SELECT LUM_Role.Name FROM `LUM_User` LEFT JOIN `LUM_Role` USING (`RoleID`) WHERE UserID='".$Comment->AuthUserID."' LIMIT 1;";


    is the key. Would you give me some more clues on how to modify it?
    •  
      CommentAuthorMr Do
    • CommentTimeMay 4th 2007 edited
     # 48
    ok here is what you do. Change GetWhosOnline function to this:
    function GetWhosOnline() {
    $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
    $s->SetMainTable("User", "u");
    $s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences","RoleID"), "u");
    $s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);
    $result = $this->Context->Database->Select($s, $this->Name, "GetRecentUsers", "An error occurred while attempting to retrieve the requested information.");
    if ($this->Context->Database->RowCount($result) == 0) {
    return NULL;
    } else {
    $my_array = array();
    while ($rows = $this->Context->Database->GetRow($result)) {
    if ($rows["Preferences"]) {
    $settings = unserialize($rows["Preferences"]);
    if (array_key_exists("Phantom", $settings))
    $phantom = ForceBool($settings["Phantom"], 0);
    else
    $phantom = false;
    } else {
    $phantom = false;
    }
    array_push($my_array, array("Name" => $rows["Name"], "UserID" => $rows["UserID"],
    "DateLastActive" => $rows["DateLastActive"], "Phantom" => $phantom, "RoleID" => $rows['RoleID']));
    }
    return $my_array;
    }
    }
    Notice how I now retrieve the RoleID. Next step is to retrieve the Role names. You do this with these lines, that you place around line 160. Directly after the if ($online_list) { line: $q = "SELECT RoleID, Name FROM `LUM_Role`;";
    $res = mysql_query($q); $role = array();
    while ($row = mysql_fetch_array($res)) {
    $tmp = $row[1];
    $tmp = str_replace(" ","",$tmp);
    $role[$row[0]] = strtolower($tmp);
    }


    Next step is change the add list like so:
    $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), GetUrl($Context->Configuration, 'account.php', '', 'u', $name["UserID"]), NULL, "title=\"$TimePast\" class=\"".$role[$name['RoleID']]."\"");
    The css bit remains the same. Hope this gets you to the finish line :)
    •  
      CommentAuthorskube
    • CommentTimeMay 9th 2007 edited
     # 49
    How about adding the ability to see who was online? And have a preference to specify how far in the past to display?

    I.E.
    [ ] show currently online visitors
    [ ] show everyone who visited in the last [15] mins
    [ ] show everyone who visited today
    •  
      CommentAuthorMr Do
    • CommentTimeMay 10th 2007
     # 50
    @skube: it is allready doing that. I mean its checking who was online in the last X minutes. There is no way for it to know who is reading a page at that exact moment. It checks for the last time it got a request from said user. It should be possible to do what you ask without much trouble