Solved

remote server online

Posted on 2003-11-13
5
259 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 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