Page 1 of 1

Server Status Script

Posted: Wed Dec 24, 2014 12:50 pm
by nasomi
Blows my mind that it was so hard to find something so simple.

Code: Select all

<?php
$sts = "<font color=#FF0000>Down</font>";
$fp = fsockopen("10.0.0.220", 54231, $errno, $errstr, 1);
if($fp !== false) $sts="<font color=#00FF00>Up</font>";
echo "Lobby Status: " . $sts;
?>
That's it. Default = down, set up if socket can be opened. Change the ip to whatever your system is. Add it to any html file and you're good to go.

Re: Server Status Script

Posted: Wed Dec 24, 2014 1:50 pm
by atom0s
I made a post somewhere on the forums that includes a function to do this already.

Code: Select all

    function get_server_status()
    {
        $socket = null;
        if (!$socket = @fsockopen( "127.0.0.1", 54230, $errno, $errstr, 1 ))
            return false;
        @fclose( $socket );
        return true;
    }
Don't forget to cleanup the socket you opened.