Jump to content

PHP server status checker

Go to solution Solved by Joveice,

Had to add a

namespace {
}

in the script

//Fixed

Hey, How would I script a script that would check if a server is offline or online and then place a Offline or Online picture on it (I have the pictures already on the server)

the server is for the game Unturned.

How would I do this?

My experience in PHP = 1/10

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/561178-php-server-status-checker/
Share on other sites

Link to post
Share on other sites

So if you want to learn

 

 

 

 

Else Here is the code to do that shit (copy the function only the last 3 lines you use to call function)
 

function ping($host,$port=80,$timeout=6)
{
        $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
        if ( ! $fsock )
        {
                return FALSE;
        }
        else
        {
                return TRUE;
        }
}


$up = ping("www.google.com");

if($up)
	echo "up";

 

 

Credit:http://www.thecave.info/php-ping-script-to-check-remote-server-or-website/

For Testing: http://phptester.net/

 

please visit the sites for ad revenue or something

 

Link to post
Share on other sites

2 hours ago, uzarnom said:

So if you want to learn

 

 

 

 

Else Here is the code to do that shit (copy the function only the last 3 lines you use to call function)
 


function ping($host,$port=80,$timeout=6)
{
        $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
        if ( ! $fsock )
        {
                return FALSE;
        }
        else
        {
                return TRUE;
        }
}


$up = ping("www.google.com");

if($up)
	echo "up";

 

 

Credit:http://www.thecave.info/php-ping-script-to-check-remote-server-or-website/

For Testing: http://phptester.net/

 

please visit the sites for ad revenue or something

 

Okey so this works for checking if my website is online or not, but when checking other stuff that I know is working like my TS3 server it returns that it's not online

Back-end developer, electronics "hacker"

Link to post
Share on other sites

21 hours ago, MSVSora said:

Try setting it to the teamspeak server's queryport instead, default is 10011

Okey so this worked tho the game servers did not they use 3 ports and I tested with all 3 and it said it was offline on all.

My idea is to get this to work automaticly (its static now) when i tested the script I used a plugin called insert-php a wordpress plugin, that worked on 1 site and only 1 at a time. I need it to be able to check 4 services at a time and to have it work in this site. How would I do this? and since it does only display a text what do I need to use for it to display a image / image with text over?

EDIT:

So I got teamspeak working on this site do it looks like when I add 2 scripts on one page it "crashes" becouse the page is just white.

Found a better plugin called XYZScripts that I'm now using.

So now it displays a Image that says Online or Offline.

So this last service Unturned uses 3 ports how will I get this to work?

And how do I add more than 1 script on each page?Test.png.eae6d9d504349bf23d1d7fcbd931eae

Back-end developer, electronics "hacker"

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×