yoshi273
02-07-2002, 07:20 PM
I wanted to write a PHP script that checks to see if a webserver is up. If it isnt, it will redirect to another server that IS up. Here is what I was thinking so far...
<?php
$sp = fopen($sitename, "r");
if($sp)
{echo "$sitename is active";}
else
{echo "$sitename is not active";}
?>
Ok, so if I use yahoo.com as the sitename, it works fine. I tried another server that I currently know is down, and it didnt tell me it wasnt active...
Is there a better way to do this? Is there a way to make this thing set a timeout to 2 seconds? Basically, when im done with this, i want to have something liek this...
if(site does not work)
header("redirect to backup site");
if(site does work)
header("redirect to normal site");
It would also be cool if I had a way to ping the servers. I could test connectivity to a user across 4 or 5 sites and send them to the best one. Got any ideas for this? Without using system commands?
<?php
$sp = fopen($sitename, "r");
if($sp)
{echo "$sitename is active";}
else
{echo "$sitename is not active";}
?>
Ok, so if I use yahoo.com as the sitename, it works fine. I tried another server that I currently know is down, and it didnt tell me it wasnt active...
Is there a better way to do this? Is there a way to make this thing set a timeout to 2 seconds? Basically, when im done with this, i want to have something liek this...
if(site does not work)
header("redirect to backup site");
if(site does work)
header("redirect to normal site");
It would also be cool if I had a way to ping the servers. I could test connectivity to a user across 4 or 5 sites and send them to the best one. Got any ideas for this? Without using system commands?