Solved

remote server online

Posted on 2003-11-13
5
253 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Responsive Design Tools 6 36
Build JSON from table records 17 38
Php Array Diff 3 26
Link SQL table to Webpage 9 35
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now