How to check if someone is online through php?
#1

I know this isn't a php forum but.. I want to know how I can check if a player is online through my UCP, how can I do this?

Example: "Luis is online" or "Luis is offline"
Reply
#2

When a player connects or logs in, update a value setting the player's online status to 1. When the player disconnects, update a value in a table/field setting the player's online status to 0. And in case the server crashes, set all player status values to 0 in OnGameModeInit.

If you don't use MySQL or a similar system, then you're not going to accurately be able to determine if a player is logged in and online, just if they're online using the connection API functions Westie released a few years ago.
Reply
#3

Quote:
Originally Posted by Calgon
Посмотреть сообщение
When a player connects or logs in, update a value setting the player's online status to 1. When the player disconnects, update a value in a table/field setting the player's online status to 0. And in case the server crashes, set all player status values to 0 in OnGameModeInit.

If you don't use MySQL or a similar system, then you're not going to accurately be able to determine if a player is logged in and online, just if they're online using the connection API functions Westie released a few years ago.
Maybe it would be easier to use PHP query Woet re released and check if string displaying online players contain word "Luis". If it is, you can return true (which means he is online) otherwise false (which means he is not online).
Reply
#4

Quote:
Originally Posted by JiHost
Посмотреть сообщение
Maybe it would be easier to use PHP query Woet re released and check if string displaying online players contain word "Luis". If it is, you can return true (which means he is online) otherwise false (which means he is not online).
Yes, but if you bothered to read my post, you'd realize that you can't accurately determine if the player is actually logged in, as you only can retrieve the player's name, ping and ID.

And I mentioned Westie's API, but I know there's other releases out there, like Woet's version.
Reply
#5

Quote:
Originally Posted by Calgon
Посмотреть сообщение
Yes, but if you bothered to read my post, you'd realize that you can't accurately determine if the player is actually logged in, as you only can retrieve the player's name, ping and ID.

And I mentioned Westie's API, but I know there's other releases out there, like Woet's version.
He should get kicked immediately if he didn't log in or someone is trying to impersonate him. So I don't think it would really be a problem.
Reply
#6

Quote:
Originally Posted by JiHost
Посмотреть сообщение
He should get kicked immediately if he didn't log in or someone is trying to impersonate him. So I don't think it would really be a problem.
Kicked so soon that they don't get a chance to enter their password? That's very silly.
Reply
#7

No, but there should be a timer which gives you max. 20 seconds to login or so.
Reply
#8

That's still exploitable then, which was my original point...
Reply
#9

The best way is saving it in MySQL yes. Ain't that hard - then you can check if the value is 1 or 0. Why checking with a query via the serverlist. That's just sad.
Reply
#10

I'm feeling glad about your attempts Luis.

Here's how I do it:
1. Server uses HTTP() to send post data to a PHP script
2. PHP script updates an array stored in cache and updates the APC entry
3. Various pages across the forum system call a specific function
4. The function loads the user list from APC and loops through it to see if the value of any entry's registration ID is the same as the one provided to the function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)