View Single Post
Old 27-02-2009, 16:12   #9
KingDaveRa
Inactive
 
Join Date: Feb 2009
Location: Aylesbury, Bucks
Age: 43
Services: Broadband Gamer, Phone M, Tivo V6.
Posts: 269
KingDaveRa is a jewel in the roughKingDaveRa is a jewel in the roughKingDaveRa is a jewel in the roughKingDaveRa is a jewel in the roughKingDaveRa is a jewel in the rough
Re: checking if a site is up and running and if not redirect

Holy crap, Python too! Ex-BY customers only though.

Here in php we have:

PHP Code:
<?php
// Try to open a socket to the server at home on port 80
$fp fsockopen("myhomesever.dyndns.net"80$errno$errstr10);
if (!
$fp) {
    
// Site is down, so we give an error - probably a PHP error too. This could be better!
    
echo "The site is down.";
    
} else {
    
// Site is up, so redirect to it
    
header('Location:http://myhomeserver.dyndns.net');
    
fclose($fp);
}
?>
Quick and dirty starter for 10.
KingDaveRa is offline   Reply With Quote