Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Undefined variables on the OnlineNow settings page

BIOSBIOS New
edited November 2014 in Vanilla 2.0 - 2.8

Well everything seems to be working with the plugin but one thing, on the profile>OnlineNow settings it is saying that there is some undefined variables such as the "UserID" and "Username" in \plugins\OnlineNow\default.php @ the line 126 which has this on it "$Sender->GetUserInfo($UserID, $Username, $UserID);"

I'm using vanilla 2.1.5, and OnlineNow 2.1 which is currently the latest and was released October 11.
http://vanillaforums.org/addon/onlinenow-plugin

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I can't reproduce the error sorry.
    That line you mention simply gets the UserID and the Username that is in a valid session logged in.

    The variable is defined in a local not global scope of the function and will never be accessible outside of it. Because the User needs to be logged in to access the settings of their profile.

    Please state what php version you are using. Enable debug mode and report back.

  • Yeah, I know it confused me to as why what it was showing as defined :s

    PHP version: 5.5.11 I believe.

    Undefined variable: UserID
    C:\xampp\htdocs\forum\plugins\OnlineNow\default.php line 126.
    C:\xampp\htdocs\forum\library\core\class.dispatcher.php line 337.
    C:\xampp\htdocs\forum\index.php line 46.
    Notice Undefined variable: Username
    C:\xampp\htdocs\forum\plugins\OnlineNow\default.php line 126.
    C:\xampp\htdocs\forum\library\core\class.dispatcher.php line 337.
    C:\xampp\htdocs\forum\index.php line 46.
    Notice Undefined variable: UserID
    C:\xampp\htdocs\forum\plugins\OnlineNow\default.php line 126.
    C:\xampp\htdocs\forum\library\core\class.dispatcher.php line 337.
    C:\xampp\htdocs\forum\index.php line 46.

    && The code on the lines^v

    C:\xampp\htdocs\forum\plugins\OnlineNow\default.php line 126. =
    $Sender->GetUserInfo($UserID, $Username, $UserID);

    C:\xampp\htdocs\forum\library\core\class.dispatcher.php line 337. =
    call_user_func_array($Callback, $Args);

    C:\xampp\htdocs\forum\index.php line 46. =
    $Dispatcher->Dispatch();

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    does the user have permissions in the dashboard to become hidden?

  • Well the user is the default admin account, would that automatically give them permission or would I have to give them it?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Have you looked in the dashboard under roles and permissions to see what the settings are checked for OnlineNow ?

  • Yeah I looked Manage and ViewHidden were unticked but the error still showed even with them ticked.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I don't get that error at all , maybe delete it and also the configs for the plugin in the config.php and try to reinstall it again. This is a very basic plugin, it checks for user valid session and gets the user name and ID and shows it in the module.

  • peregrineperegrine MVP
    edited November 2014

    the variables are undefined and give errors in debug mode when viewing settings in an individuals profile

    /profile/OnlineNow

    plugins\OnlineNow\default.php

    change around line 121 in default.php

    from

     public function ProfileController_OnlineNow_Create($Sender) {
    
          $Session = Gdn::Session();
          $Sender->EditMode(TRUE);
          $Sender->GetUserInfo($UserID, $Username, $UserID);
          $UserID = $Session->IsValid() ? $Session->UserID : 0;
    
          // Get the data
    

    to

        public function ProfileController_OnlineNow_Create($Sender) {
        $Session = Gdn::Session();
        // this tests to see is user is logged in
        if (!($Session->IsValid())) return;
        $Sender->EditMode(TRUE);
        $UserID = $Session->UserID;
        $Sender->GetUserInfo("", "", $UserID);
    
          // Get the data
    

    there might be some extraneous stuff to reduce as well.

    but this should solve the problem.

    report back if it does solve problem.

    edited.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • also in class.onlinemodulenow.php

    change lines 17 and 77 add if (!($Session->IsValid())) return; below the $Session = Gdn::Session();

        $Session = Gdn::Session();
    
    to
                   $Session = Gdn::Session();
                    if (!($Session->IsValid())) return;
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • BIOSBIOS New
    edited November 2014
    public function ProfileController_OnlineNow_Create($Sender) {
        $Session = Gdn::Session();
        // this tests to see is user is logged in
        if (!($Session->IsValid())) return;
            $Sender->EditMode(TRUE);
            $UserID = $Session->UserID;
            $Sender->GetUserInfo("", "", $UserID);
            // Get the data
    

    ^This fixed the errors, thanks.

    And I also added the session check on line 17
    $Session = Gdn::Session();
    if (!($Session->IsValid())) return;

    And on line 77
    $Session = Gdn::Session();
    if (!($Session->IsValid())) return;

    Although, when I select to be invisible on the settings it still shows me online? Is it showing me this because I'm an administrator or because I'm the one on the account(meaning only I can see me not others)

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    If you have the setting checked to view hidden people you will see them.

  • @vrijvlinder said:
    If you have the setting checked to view hidden people you will see them.

    It isn't checked but I see myself there.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Create a second test account and log in from separate browsers and see if you can or if they can see you. makes sure you empty the catch and refresh the page .

  • The test account can see it, I don't think I'd use the invisible feature anyway.

    How could I completely remove all parts of the invisible function? (I can remove the page and stuff I mean like where is the actual code for make invisible?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    No, you simply deny the ability to become hidden in the user roles and permissions page to anyone you want to deny it. No need to remove code....

Sign In or Register to comment.