Solved

remote server online

Posted on 2003-11-13
5
257 Views
Last Modified: 2006-11-17
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..."
0
Comment
Question by:boss302_lp
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:aolXFT
ID: 9742150
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......
0
 
LVL 6

Expert Comment

by:aolXFT
ID: 9742186
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.
0
 
LVL 1

Expert Comment

by:vincevincevince
ID: 9742622
if (!($a=fopen("http://server.address.com/"))) {echo "<html><script>top.location = /"/"</script></html>";close($a)}
else echo "We are experiencing technical difficulties..."
0
 

Author Comment

by:boss302_lp
ID: 9744392
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
0
 
LVL 1

Accepted Solution

by:
vincevincevince earned 125 total points
ID: 9745950
this is 100% working

<?php
$a=@fopen("http://www.experts-exchange.com/","r");
if ($a) {echo "<html><script>top.location = \"\"</script></html>";close($a);}
else echo "We are experiencing technical difficulties..."
?>

sorry, i had a typo in the last one
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question