Solved

remote server online

Posted on 2003-11-13
5
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

617 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