Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
1.1k views
in Plugins by
I am tryign to get all online user list (not current/single user ). It is easy to get current logged in user with qa_is_logged_in but this is not working for all logged in user.

Any advice to get all logged and offline in user list
by
I found some other way by creating custom column. Will update once finished.

1 Answer

+1 vote
by

We prepared a script for our q2a website, https://github.com/askdevopsorg/demo/blob/master/scripts/c.php

Live demo at http://www.askdevops.org/

A Simple PHP script to show online user count.

How it works?

JQuery is used to call this file, /c.php

Server side data is stored in qa-cache/mydat.txt

INSTALLATION:

1. Copy the below files to the root of Q2A website

   c.php

   qa-cache/mydat.txt

2. Paste the below code where you need to display the online user count

   <script>$(window).on('load', function() {$("#_c1").load("/c.php");});</script><span id="_c1">..</span>

by
edited by
i tried it but it stick on 0 online
by
Thanks, I see the issue, you have to reload the page to display the current count!
I will fix it
by
+1
i have figured the problem
i'm using a local server so this line

$ip = $_SERVER["REMOTE_ADDR"];

will not work probably ... i'm using this code to get the rial visitors IP

// Function to get the client ip address
function get_client_ip_env() {
    $ipaddress = '';
    if (getenv('HTTP_CLIENT_IP'))
        $ipaddress = getenv('HTTP_CLIENT_IP');
    else if(getenv('HTTP_X_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
    else if(getenv('HTTP_X_FORWARDED'))
        $ipaddress = getenv('HTTP_X_FORWARDED');
    else if(getenv('HTTP_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_FORWARDED_FOR');
    else if(getenv('HTTP_FORWARDED'))
        $ipaddress = getenv('HTTP_FORWARDED');
    else if(getenv('REMOTE_ADDR'))
        $ipaddress = getenv('REMOTE_ADDR');
    else
        $ipaddress = 'UNKNOWN';
 
    return $ipaddress;
}


i tried every single line but didn't work also ..
can you update the function so can every 1 use it
by
Thanks again, I have updated the script., you may edit in github too, please join me there..
by
i have updated the file but still stuck on Online: 0
...