Jump to content

Recommended Posts

ok so i been workin on a script that shows if a server is online/offline (got that working) but now i want to get it for it can show users that are online on a ip address and port heres the code that shows if the server is online/offline

 

<?php
$IP = array(
"ip1:" => "85.13.214.87:9998"
);

while(list($ServerName,$Host)=each($IP))
{
    list($IPAddress,$Port)=explode(":",$Host);
    if($fp = @fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,5))
    {
        fclose($fp);
        echo "<img src='online.gif'> <font color='green'>Online</font><br>";
    }
    else
    {
        echo "<img src='offline.gif'> <font color='green'>Offline</font><br>";
    }
}
?>

 

so if someone could help me figure out how to make it show the number of users that are connected to: 85.13.214.87:9998 and for it prints somehting like "Users: #" i would love you, thanks

Link to comment
https://forums.phpfreaks.com/topic/170332-users-online-script/
Share on other sites

You can't. Is 85.13.214.87 your server? If it is than on port.. 9998 you must define a gateway that writes the user to a temporary file that'll expire after X amount of minutes.. which will display the current online users in a more or less accurate method, that's what sites do to list online users..

Link to comment
https://forums.phpfreaks.com/topic/170332-users-online-script/#findComment-898562
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.