Server Status Script

Applications/Tools written to make running DarkStar easier for the rest of us.
Post Reply
nasomi
Posts: 141
Joined: Wed Feb 13, 2013 8:51 am

Server Status Script

Post by nasomi » Wed Dec 24, 2014 12:50 pm

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.

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: Server Status Script

Post by atom0s » Wed Dec 24, 2014 1:50 pm

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.

Post Reply