• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

status checker

Hultin

Member
Joined
Dec 2, 2008
Messages
262
Reaction score
17
Hello!

I'm building my own ACC website from scratch using PHP 5.3.

It's gone great without any issues so far, but now, when I try to create a "online status" page I've realised that I really have no idea how to make one of thoose, the only other thing besides php scripts I've worked with is torrent-clients and they use querystrings to get the job done, so I decided to ask for help with this issue.

I just want to list how many players are online, and only if the server itself is online.

/Hultin
 
If you have started on an AAC from scratch, shouldn't you know how to do a simple query?
 
There's a diffrence between doing a simple sql-query and checking if the server is online, say the server crashes and some character are still flagged as online. Then that would reflect as the server being online on the website, while in reality, it's not.

I'm therefore looking for a way to either modify the core to perhaps update a *.txt file every 10-15 seconds with some server info, such as ammount of online players and a timestamp etc so I could compare that value to the value on the website.
 
Oh, if the server is online, guess I missed that part, sorry. Well I think you could do something like this:


PHP:
<?php

function serverOnline($ip, $port, $timeout)
{
	$socket = fsockopen($ip, $port, $errno, $errstr, $timeout);
	if (!$socket)
	{
		return false;
	} 
	else
	{
		return true;
	}
}
?>

Call it;
PHP:
serverOnline('127.0.0.1', 7171, 5)

I haven't tested it as I do not have access to a php server but I think it should work
 
Ah,how could I not think of fsockopen.

Just modified it a very tiny bit,
PHP:
function serverstatus($ip, $port, $timeout){
    $socket = @fsockopen($ip, $port, $errno, $errstr, $timeout);
    if(!$socket){
        return false;
    } else {
        return true;
    }
}

added the @ to avoid it showing a looooooong error incase the server was indeed offline.
 
How would I go about to try to "mine" data from the server, ot engine if you will, to findout a uptime?
 
Back
Top