Link to home
Start Free TrialLog in
Avatar of boss302_lp
boss302_lp

asked on

remote server online

i need a php script that will check to see if a remote server is online

if this server is online it will output the html code:

<html><script>top.location = ""</script></html>

if the server is offline it will just echo the text "We are experiencing technical difficulties..."
Avatar of aolXFT
aolXFT

One way would be to ping it,

check out http://www.hotscripts.com/Detailed/11461.html

Another way would be to make a request to it at port 80, and if it is successful, you are okay, and if it fails......
If you want to request to port 80 check out the following.

#############################
<?php

$sock = fsockopen("www.remote-server.com", 80);

if(!$sock){ ?>
We are having server difficulties....
<?php } else {
fclose($sock);
}

#############################

I haven't checked out the php-ping package, I just found it on google.
if (!($a=fopen("http://server.address.com/"))) {echo "<html><script>top.location = /"/"</script></html>";close($a)}
else echo "We are experiencing technical difficulties..."
Avatar of boss302_lp

ASKER

ping wont seem to work, and my server is on 8080, so i'd need the other two script to check on 8080, but when i modify any of the scripts to suit my needs, i get no output, as well i tried this to check if experts-exchange.com was online, and still nothing
ASKER CERTIFIED SOLUTION
Avatar of vincevincevince
vincevincevince

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial